You can go to Peru basically all year round. However, the best weather for visiting Machu Picchu should be between May and September, or even between June and August, but then you have to be prepared for crowds.
I was in Peru at the end of March/beginning of April; and in some places you could still experience the power of last raining season (on the picture).