Mexico is such a huge country that the weather varies by region and season - at any one time part of the country will be at its best.
In general the best time of year to visit is between November and April when there is virtually no rain. The coldest months are between December and February when high northern regions such as the Copper Canyon can be severely disrupted by snow. The ‘rainy’ season begins in the south in May and runs until October. Although it can be hotter and more humid at this time of year, usually it only rains for a couple of hours before the weather clears.
The Caribbean coast can be affected by the hurricane season, which is generally from June to November.