It’s best to hike Rainbow Mountain during Cusco’s dry season because, let’s be honest, no one wants to do a strenuous hike in the rain.
The dry season falls between April and November, with Rainbow Mountain being at its busiest (and therefore most crowded) during June, July, and August. So if you visit between April and May or September and November, you’ll get the best of both worlds: fewer crowds and better weather.
During the rainy season, the trail can be wet and muddy, making the hike even more difficult. Visibility is also often poor during this time, meaning that you get relatively little reward for all of your effort. There are also sometimes mudslides that block the road, making it impossible to reach Rainbow Mountain at all.
It’s also best to avoid hiking the mountain on the weekend because this is when many locals visit Rainbow Mountain, and the trail can get very crowded.
As for the best time of day, you should try and avoid midday. Hiking between 7-9 am, or after 2 pm will help you to avoid the crowds and make the most of your time on the mountain.
I will say that hiking early means leaving Cusco between 3-4 am, but Rainbow Mountain is definitely worth sacrificing a night of sleep for.