Most people take the A7 and are in Marrakesh in time for lunch. It is a good motorway and there is nothing wrong with that. But if you have the day, there are two alternatives worth the extra hours.
The A7 motorway — 240 km, about 3 hours
Toll is roughly 90 MAD. Two service areas with decent coffee. Cruise at 120 and you will be there before you have finished your playlist. This is the right choice if you are collecting a car at Mohammed V airport after a long flight.
The coast road via El Jadida and Oualidia — about 8 hours with stops
Head south on the coast to El Jadida for the Portuguese cistern, then on to Oualidia for the lagoon and the oysters. The oysters are the point of this route. Turn inland at Safi and join the road to Marrakesh through the Chiadma country. The surface is good throughout.
The inland route via Benguerir and the Rehamna plain — about 4 hours
Slower than the motorway but free, and it goes through real working Morocco: phosphate towns, argan scrub, and roadside stalls selling melons in summer. Take this one if you want to see the country between the cities rather than a barrier fence.
Which car
For the motorway anything does. For the coast road take something comfortable — the Golf or the Tucson. For the inland route, ground clearance helps where the shoulder is broken.