One of the largest questions I had going to Morocco was clothing. I have visited Arabic countries before and had never had an issue with the dress code. As long as I dressed modestly, I was usually fine.
Morocco was no exception to this rule. Northern Morocco and major cities like Fez and Marrakech were very laid back. Most women were dressed in long pants or long dresses with their heads covered. Their wardrobes were colorful and the dress code seemed relaxed. Many tourists I saw were wearing shorts and tank tops and no one seemed to care.
This changed a bit once my friends and I were on the border of Algeria and driving south towards the Sahara Desert. Most of the women were wearing traditional hijabs and dressed in all black robes. It seemed more strict and modest in this particular area of the country. Even still, we were dressed in long pants and t-shirts and no one treated us differently.

Morocco in general is hot. Wearing loose clothing is the best tip I have. Jeans wouldn't be my recommendation. Comfortable clothing for lots of walking in the medinas and loose tops that are a breathable fabric make for the ideal wardrobe. As always, be practical. The streets can be quite dirty and/or dusty so go with tennis shoes or buy the local leather shoes sold in every market.
At times, I kept my head covered, but in general, I couldn't seem to master the art of tying and keeping a wrap on to save my life. And, to be honest, I have a lot of hair and that thing was hot! I did my best in moments where I felt it was called for, but often, I went without a head scarf. And, again, no one seemed to treat me any certain way based on my lack of head covering.
With that said, if you are going to the Sahara Desert, then, you might want one. It has nothing to do with customs or religion but rather everything to do with the practicality of staying in a desert surrounded by loads sand, sun, and wind! You can find all sorts of scarves in the markets which are both great to use and also make for an awesome souvenir.
In general, I think the goal of dressing modestly isn't for fear of mis-treatment. It is simply to respect the customs of the culture & religion.
