Marrakech was built to impress people arriving from the desert. The Almoravids founded it around 1070 as a capital between the Atlas and the Sahara, and the red walls that give it the nickname the Red City date from 1122-1123. Dynasties came and went, the Saadians built palaces here and a later sultan stripped them for parts, and the French added a new town outside the walls. Most of it is still standing, in the same pink-red earth.
It's a city of intense contrast, and you should know that before you land. The medina is among the most beautiful old towns in North Africa and also the place where you'll be told that your hotel is closed by a stranger with a very good story. Marrakech is loud, hot in summer, and relentless about selling you things. It's also where a 16th-century madrasa, a ruined palace, a cobalt blue garden and a square full of smoke and drums sit within a taxi ride of each other. Five days gives you time to do the sights early, go back to your riad when the midday crowds peak, and come out again at night.
The plan keeps each day in one part of town. Day one is the square, the souks and the madrasa, day two the Kasbah quarter with the tombs and the palaces, day three the new town, the Majorelle Garden and a hammam, day four the northern medina and its smaller museums, and day five a day trip up into the Atlas. For the rest of the country and what to read next, see Morocco. Start on a Thursday if you can: the Yves Saint Laurent Museum is closed on Wednesdays, and this order puts it on day three, a Saturday.