The number of days needed 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 such as the Atlas Valley and the Sahara Desert, then you will probably need at least a week.
However, if you have more time available, there is much more to see and do in Morocco. For example, you can also visit the Atlantic coast, Casablanca, Essaouira, and Toubkal National Park, among others. There are also many opportunities for hiking and climbing in the Atlas Mountains, and to experience the local culture through activities such as Gnawa dancing and traditional music.
In short, the number of days needed to visit Morocco depends on your interests and priorities, but a minimum of one week is generally recommended to get a good feel for the country and its main attractions.