Don't be scared to go it alone in Morocco if you're a female!
No doubt, you will be approached/hassled to buy a tacky souvenir, eat at a certain restaurant or asked for money just about every minute while walking through a busy market, but walk quickly and with confidence and you can still get by.
Moroccans are very welcoming people and in my experience, take a firm "no!" for an answer when you don't want to be bothered. I spent a week traveling solo from Agadir, to Marrakesh, to Essaouira and the Ourika Valley and never feared for my safety.
Yes, it is very easy to get lost in those windy roads of the markets and the crowds and chaos can be bewildering, but you can find sanctuary and beauty to escape to easily.
Some men will ask to talk to you and ask you out for a coffee. If you are not interested, just say "no" and keep walking. I also found they left me alone quicker if I said I was married (which I am) and showed my wedding ring. You also have the option of covering your hair with a hijab. I found I was bothered less when I did that, however during one afternoon prayer, someone tried to pull me into a mosque (and I regret not going in to see).
If you are already shopping at a stall and the owner invites you to sit and have mint tea, it's hard to resist and can be fun. In my experience, they were happy to show me pictures of their family and country, as well as ask me about my home life. Though I'll admit, I had so much mint tea while I was there, I started to get a heartburn just thinking about another glass!
Similarily, if you are invited to their home for a meal, I think you can feel safe doing so. Even when they do not have a lot to offer, they are very giving and love to ask questions about your life and travels. I always carry small souvenirs and postcards from my city to give to people as thank you gifts. Don't be shy to give a little bit of money to pay for your meal, or there may be an item you have and take for granted that they may want or need. For example, I gave a shopkeeper's wife who made me lunch my sunglasses. She liked them and almost cried with joy when I gave them to her.
I don't know too many other countries where you can get such insight into the daily life of the people in such an intimate way. They are genuinely curious to learn more about you, especially fellow women.
On the more negative side, I did have my arm grabbed once by an over-zealous shopkeeper trying to get me to look in his store. I turned around and loudly told him to let me go. When he did not, I raised my fist, threatening to punch him and he ran away. Do not be scared to cause a scene if you need to. He was the most annoying heckler I got, so he is not representative of the people. That was also in Marrakesh, which is a bit more busy and wild than the smaller cities, like Essaouira.
It helps and gives you better service and respect if you can speak French - and I'm sure you'll get even better deals if you can speak Arabic. Even without those skills, I have no qualms advising ladies to go ahead and enjoy the country alone. Dress like the locals and keep an open mind. Take the time to talk to and get to know the locals. I did not sense any danger taking buses, taxis or traveling at night alone.
A visit to Morocco is well worth it!