It's possible that the President is simply far more popular than people outside Iran want to believe. There's no doubt that he has won the support of many voters by focusing on Iran's nuclear ambitions and by playing up the perceived threats from Washington and Israel.
At the same time, Iran's economy is a mess, and people are unhappy about a raft of everyday issues, from the price of food to joblessness.
The result is also surprising in light of Iran's demographic trends. There is a lot of evidence that as the country grows younger, it is also growing more moderate. A reform candidate won Iran's presidency with 70% of the vote in 1997 and increased his share to 78% four years later. In 2005, the reform movement had fallen on lean times and many young voters stayed at home; Ahmadinejad squeaked into the presidency in a second round of voting widely seen as having been tampered with. If the results this time are legitimate, it means that two-thirds of Iran's voters have become more conservative over the past four years.
It's also worth noting that big turnouts are often a sign that voters want change and tend to favor the challenger. This time around, by contrast, the incumbent President won two-thirds of the votes cast, according to the government.