My husband and I were in Marrakech a couple months ago and we felt safe the entire time. A girlfriend of mine from California visited Morocco for three weeks by herself and she said she felt safe too. She said that did get A LOT of unwanted attention, but after a while she learned to just ignore unwanted advances and she had a great trip.
Be sure to dress conservatively, (no matter if you are traveling alone or not) it helps to cut down on unwanted attention.
Good luck… have a great trip!