Map from Google - Yucatan

The Yucatan Peninsula, which includes the Mexican states of Yucatan, Campeche and Quintana Roo, but also a part of Belize and Guatemala, has a tropical climate, with a rainy and muggy season from June to October, a relatively cool season from November to February, and a hot season from March to May, when the highest temperatures of the year are reached, with peaks of more than 40 °C. This heating before the rainy season is particularly pronounced in the western and southern parts of the peninsula, in cities such as Merida and Campeche, on the coast of the Gulf of Mexico, and in inland areas where the ruins of the Mayas are found, while it's felt less along the east coast of the Caribbean Sea, that is, in Cancun and the Riviera Maya.
Here are the average temperatures of Pisté, situated near the archaeological site of Chichén Itzá, in the interior of the peninsula.
Average temperatures - Pisté
PistéJanFebMarAprMayJunJulAugSepOctNovDec
PistéJFMAMJJASOND
Min (°C)141517182021212020191715
Max (°C)293033343534333333313029

Precipitation goes between 900/1,000 millimetres per year in the west coast, and 1,200/1,400 mm in the east; the rainiest period, as mentioned, goes from June to October.
Here is the average precipitation.
Average precipitation - Pisté
PistéJanFebMarAprMayJunJulAugSepOctNovDecYear
PistéJFMAMJJASONDY
Prec. (mm)454035459017016017020013060401185
Days54337121415151165100

In winter, from November to February, the temperatures are high, so that highs swing around 28/30 degrees, while lows are pretty cool, around 15 degrees, at least in inland and northern areas. Weather fronts pass frequently from the United States, bringing a bit of rain and followed by a cool wind, el norte, which can lower the temperature at night around 10/12 °C, and during the day around 20/22 °C.
Starting from February, the temperature begins to rise, at least in inland and western areas, so that the temperature can easily exceed 30 degrees, although the norte comes back often, lowering the temperature, until mid-March.

Spring, from March to May, is actually the hottest season of the year, especially in inland and western areas: highs in April and May in Campeche and Mérida are normally around 35/36 degrees, but they exceed 40 °C with relative ease. Along the east coast, in the Riviera Maya, the heating is less pronounced, although there's still a increase in temperature and humidity. In May some thunderstorm activity begins to occur, due to the heating of the ground.

Cenote Ik Kil

Summer, or rather the rainy season, from June to October, is hot and muggy, with many hours of sunshine, but also with downpours or thunderstorms. There is also the risk of hurricanes, from June to November (but with a higher probability from August to October). During periods of good weather, however, it can still be very hot, with highs above 35 degrees.

The sunshine amount in Yucatán is good all year round, but especially from March to May, ie after winter and before the rainy season. In winter there can be some cloudiness associated with cold fronts from the north, while in the rainy season, when however there's no shortage of sunshine, areas of instability can form, associated with thunderstorms, but also some irregular cloudiness, while the sky can be covered with clouds for several consecutive hours during hurricanes, which fortunately are relatively rare.

Chichen Itza

For swimming, the sea is warm all year round, as we can see in the following table, regarding the temperature of the sea at Campeche.
Sea temperature - Campeche
CampecheJanFebMarAprMayJunJulAugSepOctNovDec
CampecheJFMAMJJASOND
Sea (°C)252525262829292929282727

When to go

The best time to visit Yucatan and hike in the Mayan archaeological sites goes from December to February, being the least hot and humid of the year. By day it can be hot, so you should bring hat and sunglasses; at other times it is fine during the day, while at night it can be even a little cold: better to bring a sweatshirt or sweater for safety.
In November the weather is already similar to that of winter, but we are still in the hurricane season.
In February it can already be very hot, so the best months are December and January. Those who can stand the heat can also go from March to May, since it is still the dry season, but you must take into account the heat which can sometimes be oppressive, with peaks above 40 degrees, especially in May, when also early afternoon thunderstorms begin to occur. On hot days, however, you can escape in the cenotes, caves with natural pools of fresh water.
As we have seen, for swimming in Yucatán the sea is warm enough all year round, although from December to mid-March sometimes the air is a bit cool and the sky is cloudy.