In Cancun, the weather is always sunny but pleasant. Being a sea side town the breezes stop the temperatures from soaring too high even in summer. Moreover, there is no price for hiking during the tourist season (which is in winter). In short, any time is the best time to visit Cancun.
Wet Season (May to October): August and September are probably the hottest months here. If you wish to avoid the heat avoid these months. In May the weather is just perfect and the days are long and lovely and is good season to visit this place. It rains quite often since it is a tropical country so; do carry an umbrella unless you are going in winter.
Off Season: The Hurricane season starts in June and lasts till the end of October so if you are wondering when to visit Cancun, this is not really the preferred time. Since not many tourists prefer this time, May to August is considered to be an off season.
Dry Season (November to April): Tourists from colder countries prefer to visit during winter. The weather is simply divine. It is neither too cold nor is there any scorching heat. You can actually enjoy the sun and sand during winter without getting terrible sunburn. It is certainly the best time of the year to visit Cancun. December and February (especially if you plan to get married here) are tourist favourites and a peak season. Humidity is lowest in April.