Timing purely depends on what you want to do in Morocco but here is a breakdown of what the best time to visit for each activity.
January and February
It is winter and temperatures are very low ( not as bad as December and November) most people who visit around this time head to Ifrane a small skiing town in the Atlas mountains. The festival of almond blossoms also happens in February in Tafraoute.
March and April
Temperatures begin rising, it's the best time to visit most of the popular attractions such as the tanneries in Fez and doing outdoors activities.
May, June, July, August
These are the hottest months, however one of the best times to visit. Souks are very lively during these months. Ramadhan and Eid usually take place within these months.
It's also the best time to visit coastal towns.
One of the biggest festivals in Morocco, the Moussem Moulay Abdellah amghar takes place in El Jedida in August.
September and October
Its the beginning of autumn and the weather is similar to that one in spring. Also a great time for outdoor activities.
November and December
I discourage anyone from visiting during this time especially when going to interior Morocco. Winters are tough here and moving around can be a real hustle.