Morocco is a Muslim country and respecting the local culture is important. It just makes for a nicer trip and not constantly being harassed. Women can wear what they want in hotels and bars dedicated to tourists, but they should try and cover up everywhere else. While it isn’t illegal for women to wear shorts, you’ll attract a lot of unwanted attention if you do. Skirts that go below the knee and long-sleeved tops rather than strappy t-shirts are ideal. Men are fine in shorts and shirts.