Spring and autumn are by far the best times to visit Iraq. The heat in summer is genuinely extreme and makes outdoor sightseeing — which is most of what Iraq offers — unpleasant and potentially dangerous.
Spring (March to May) is the ideal window. Temperatures are mild, the landscape is green, and wildflowers bloom in the north. March and April are probably the best months. By late May the heat is building fast.
Autumn (October and November) is the second good window. Temperatures have dropped from the summer peak, skies are clear, and the light on archaeological sites is beautiful. This is a popular time for organized tours.
Summer (June to September) brings extreme heat across much of the country. Temperatures in Baghdad and the south regularly exceed 45°C. Basra has recorded 53°C. Shade and air conditioning become survival necessities rather than luxuries. The Kurdistan Region is cooler — Erbil and Sulaymaniyah are popular summer retreats for Iraqi families from the south — but still hot by most standards.
Winter (December to February) is mild in Baghdad and the south, with some rain. In the Kurdistan mountains it can be genuinely cold and snowy. This is not a bad time to visit the south or Baghdad if you can tolerate occasional rain and cool evenings.
If you are planning to visit Karbala or Najaf for the Shia pilgrimage observances — Arbaeen in particular, which draws tens of millions of pilgrims each year — plan well in advance. The cities fill to an extraordinary degree and movement becomes very difficult.