The busy tourist season at Machu Picchu runs from June to August, when the site can get as many as 3,000 visitors in one day.
From May to October, weather is generally mild at Machu Picchu, with temperatures cool and little rain (typically averaging just two days of rain a month). Peru's rainy season is from December to April, when the weather is warmer and rain showers are common (averaging 13 days of rain a month).
During February, the Inca Trail, which is a 26-mile trail that leads to Machu Picchu, is closed due to the rain. This does not mean that Machu Picchu itself is closed, only that this famous four-day hike is unavailable.
If you hope to visit Machu Picchu when there are fewer people, consider going on Tuesdays, Thursdays and Sundays, when the nearby town of Pisac has its large craft market. Tour groups tend to stop at the market, leaving the ruins of Machu Picchu relatively quiet.
The best time of day to visit Machu Picchu tends to be either early in the day (before sunrise), or later in the day (after 3 p.m.), when most tour groups have left.