Peru has one question that matters more than the rest: are the high passes open?
From May to September the Andes are dry. Mornings start near freezing and days run bright and clear, the trekking routes are reliable, and the Inca Trail runs. This is also when Cusco and Machu Picchu are busiest, which is the trade you are making. May and September are the sweet spots at either edge.
From December to March the highlands take heavy afternoon rain. High roads become unreliable and the Inca Trail closes entirely every February for maintenance. What people miss is that this barely touches the rest of the country: Lima's desert coast is at its brightest in those months, and the Amazon is workable year-round.
So the season does not decide whether to come. It decides the shape of the route.

