Chiang Mai was founded in 1296 as the new capital (the name means new city) of Lan Na, the northern kingdom that ran from the 13th to the 18th century. Its kings planned a neat square town, put a moat around it and filled it with temples, and the square is still there: the Old City is a one-mile box of moat and surviving brick wall with temples on almost every street. The city fell to Burma in 1556, became part of the Thai realm in 1774, and was abandoned between 1776 and 1791 during the Burmese counterattacks. Lanna culture survived all of it, and you can still taste it in the food.
It's not a beach town and not Bangkok. It's a mid-sized city with a mountain and a famous temple 17 km away, cool mornings from November to January, and a food scene built on sticky rice, herbs and chili dips rather than coconut and sugar. Five days is the right length: two days for the Old City and its temples, one for the mountain, one for markets and cooking, and one long day trip to Chiang Rai. It also gets you through a Saturday and a Sunday, which matters, because those are the nights the streets close for the walking-street markets.
The plan is organized by area and by weekday. Start on a Friday: day one is the Old City temples, day two Warorot Market, a cooking class and the Saturday market, day three Doi Suthep and the Sunday market, day four the Chiang Rai temples, day five Nimman, a careful elephant visit and street food. Both walking-street markets, and the Chiang Rai day, land on the days they work best. If you arrive on another day, swap the order, but keep Saturday and Sunday evenings for the markets. For the bigger picture of the country, read our page on Thailand.