Rabat is an excellent place to get acquainted with Morocco, as it has a medina and an array of historical sites and museums, yet exerts significantly less of the pressure that most foreign travelers experience in a place like Fez. You'll generally find yourself free to wander and browse without being hassled to buy local wares or engage a guide. As a diplomatic center, Rabat has a large community of foreign residents. Attractive and well kept, with several gardens, it's arguably Morocco's most pleasant and easygoing city as far as tourists are concerned.
Rabat was founded in the 12th century as a fortified town—now the Kasbah des Oudayas—on a rocky outcrop overlooking the River Bou Regreg by Abd al-Mu'min of the Almohad dynasty. Abd al-Mu'min's grandson, Yaqoub al-Mansour, extended the city to encompass the present-day medina, surrounded it with ramparts (some of which still stand), and erected a mosque, from which the unfinished Hassan Tower protrudes as Rabat's principal landmark. Chellah, a neighboring Roman town now within Rabat, was developed as a necropolis in the 13th century.
In the early 17th century Rabat itself was revived with the arrival of the Muslims, who populated the present-day medina upon their expulsion from Spain. Over the course of the 17th century the Kasbah des Oudayas grew notorious for its pirates, and an independent republic of the Bou Regreg was established, based in the kasbah; the piracy continued when the republic was integrated into the Alaouite kingdom and lasted until the 19th century. Rabat was named the administrative capital of the country at the beginning of the French protectorate in 1912, and it remained the capital of the Alaouite kingdom when independence was restored in 1956.
The city has grown considerably over the last 20 years, and today it has many important districts outside the kasbah, the medina, and the original French Ville Nouvelle. These include L'Océan, the seaside area that was once Spanish and Portuguese (during the French protectorate); Hassan, the environs of the Hassan tower; Agdal, a fashionable residential and business district; Ryad, an upscale residential district; and Souissi, an affluent enclave of wealthy folks and diplomats. Take a ride in a taxi, a tram, or your own car around the various neighborhoods to get a real understanding of the city as a whole.