The number of days you need to visit Morocco depends on your interests and priorities. If you want to see the main tourist attractions, such as the imperial cities of Rabat, Meknes, Fes, and Marrakech, as well as some of the natural attractions like the Atlas Mountains and the Sahara Desert, then you'll probably need at least a week.
However, if you have more time, there's much more to see and do in Morocco. For example, you can also visit the Atlantic coast, the city of Casablanca, the city of Essaouira, Toubkal National Park, and more. There are also many opportunities for hiking and climbing in the Atlas Mountains and for experiencing the local culture through activities like Gnawa dancing and traditional music.
In short, the number of days you need to visit Morocco depends on your interests and priorities, but a week is generally recommended as a minimum to get a good feel for the country and its main attractions.