This is a link out of Michigan State University that looks at past U.S. presidential elections based on how close they were.
Specifically, they look at each losing candidate, and the popular vote difference in the states they lost. Based on the number of electoral votes they were behind, this study determines the minimum number of popular votes, and in which states they would have had to have occurred in to change the outcome.
No shock: of the 43 elections under analysis, the 2000 was the closest. A mere 270 switched votes in one state (I forget which one, but I think it was in the southeast) would have changed the outcome. By comparison, 2004 was a runaway: a little under 60,000 votes in three states (New Mexico, Iowa, and Colorado) would have had to change the outcome.
Three outcomes shocked me: I never realized that Gerald Ford came so close to winning an election outright: a change of under 10,000 votes in Ohio and Hawaii would have denied Jimmy Carter the White House.
The biggest blowout in terms of number of voters needed to change, and 41st in terms of a percentage of the electorate was the Nixon-McGovern election of 1972. Despite Watergate starting up, McGovern would have needed over 3.1 million votes in 26 states to change hands to dethrone Nixon.
I was always under the impression that Daley and his machine politics delivered Illinois at the last minute to give Kennedy the 1960 election. It looks like Nixon needed more than that, but not that much: less than 12,000 votes spread over Hawaii, New Mexico, Nevada, Illinois, and Missouri would have swung the election (forget Illinois, Hawaii was only 58 votes away from going Nixon! …. Illinois needed a change of over 4400 out of over 4.7 million votes cast).
All in all it was an interesting look at how close some losing candidates got to being elected, and how others never stood a chance.
if you scroll down on that website, it there is more analysis, of which the most interesting: how often does a particular state hang in that purple zone: where the popular outcome was close enough that it was one of the closest state in the election that it could have helped swing the results. New Mexico, despite having few electoral votes, and only having been in 24 elections through 2004, has been in this zone 17 times, a higher percentage than any other state.