Egypt, being a predominantly Muslim country, is naturally conservative (not like the Gulf States or Saudi Arabia) but the average people are careful in what they wear. The dress code in Egypt for women is considered conservative by western standards and it is respectful to obey this code.
For men it is not really an issue -- normal trousers and shirt or T-shirt are fine -- but in Cairo it would not be acceptable to wear short shorts or a tank tops/sleeveless tops. In the resorts like Sharm El Sheik, Hurghada, Sinai, etc. -- shorts are fine and it is very open and flexible. This also applies to ladies for the beach areas, but going into the market area in Hurghada, for example you may be more comfortable in trousers. Generally for men in Cairo or any city that is not on the sea side, remain with trousers (at tourist sites long loose shorts) or jeans and T-shirt , as even in Cairo, local people do not feel comfortable seeing a man in shorts. In Sea Side areas it's ok to walk in shorts, but once you enter a local restuarant or market, it's better to be more covered.
So, the main subject here is what women should wear. Adopting the conservative dress code will hopefully deflect unwanted attention from the Egyptian men, which for most women is desirable. Basic clothes could include loose linen/cotton trousers or a below knee skirt and sleeved blouse. (If you're planning to ride a camel, a skirt is not a good idea.) Tight clothes and low necks are to be avoided. Also aviod transparant blouses or pants as they are also not welcomed and will draw attention and even comments, especially from young men.
Going out to dinner, especially in a nice restaurant, it is advisable to wear smart clothes and having a shawl to cover bare shoulders would be a good idea. On cruise boats, also, it is nice to have something smart to wear in the evening.
Comfortable, strong shoes are a must (that could be sneakers/trainers or good leather shoes). Sandals can be worn, but you will suffer from dust /sand and the streets of Cairo are not clean; there are often mud puddles, too, so, in general, having closed shoes is the better option. This is not the time to make a fashion statement. It will be difficult to see sights in heels of any sort, as the desert is sandy.
When entering a mosque as a tourist it is better to observe the conservative dress code as above, and in some of the major mosques (Al-Azhar for example) women will be required to cover up and this is provided by the mosque. Some mosques ( i.e., Ibn Touloun) have canvas shoe covers (not easy to walk in), so it is possible to decline, but Ibn Touloun mosque is not in use for daily services, so it is not always very clean, and using the shoe covers can be good for the areas that have no carpets like the central court. For other mosques like Mohamed Ali or any other, just remove your shoes and walk in socks. Any Muslim entering a mosque for prayer will simply remove his/her shoes, so why should a tourist be different? The best option for most people when entering a mosque is to leave the shoes with the mosque guard, who usually has a desk at the entrance and a place to store shoes. He will keep an eye on them. When leaving you can give him 1 egyptian pound or even half a pound, or nothing. Usually locals give half a pound just because he is a poor man, but it is not obligatory. Some of these guards are greedy when they see a tourist, and they ask you for money, but if you do not want to pay, just leave. He can't force you to pay anything and he doesn't have the right to even mention that a certain amount of money should be paid.
In winter it can get cold at night in Egypt. Often it is warmer in the street than it is inside buildings, so it is a good idea to bring a casual jacket or shawl. The buildings are designed to be cool and it is good to be aware of this. Here it's very rare to have central heating or central air conditioning except in big hotels and other high class places.
So, to "fit in," the above is highly recommended. This applies to any of the major cities in Egypt, excluding the Red Sea resorts, which are much more easy going. But while traveling by road between destinations (with police check points, petrol stations, etc.) covering up more would be wise. Also, when in Upper Egypt, it is best to be more covered and for women to not wear extreme makeup, as this will only attract more unwanted attention.
Some tourists wear what they like (tank tops, sun dresses, short shorts, low necks, see- through blouses) - without any consideration for the local culture or customs. This can be done, of course, and the tourists then imagine that this is ok (and strongly recommend it to others). But, in fact, having done it without having comments made directly to them or encountering trouble, it still does not make it the right choice. They are oblivious to the very bad impression they have left behind.