Why it's the capital
When France made Morocco a protectorate in 1912, the French administrator Hubert Lyautey moved the capital from Fez to Rabat, which he found more pleasant and easier to reach on the coast. At independence in 1956, King Mohammed V chose to keep the capital in Rabat.