McCain won the GOP nomination by inertia, by hanging around long enough for the bottom feeders around him to expose themselves as the weakest Republican field in many memories. Fred Thompson thought we were still fighting the cold war, Mike Huckabee thinks the earth is 6,000 years old, and Mitt Romney's political gyrating makes McCain's positions on the issues look absolutely static by comparison. McCain became the winner by default - he got the "I guess vote", as in "Who do you support?", "I guess McCain". He was the only one not clearly an idiot, a loony, or politically unprincipled.
Once he got the nomination, he had to get the support of those factions to have any hope of winning, so he become politically unprincipled, and choose a loony idiot as a running mate. The real message of this election is that the Republican Party is going to have to revamp itself, and/or its political strategies, to have any hope of being competitive on the national scale again.