Palin was picked because she was a rising star in the conservative movement. If not Palin, then McCain will need another conservative rising star.
McCain's problem was that being a "Maverick" he tended to alienate many in his own party. To even have a fighting chance, McCain has to shake up the race and get conservatives on board, not just as voters, but as participants in the campaign. Palin fit that requirement.
Palin was young, had a good overall track record in Alaska, and was generally well thought of nationally. Unfortunately, after a good debut, her candidacy was hit with a quadruple whammy of problems. An ill-timed family crisis, extremely poor media management by the McCain campaign, infighting in the McCain campaign, and one of the worst cases of character assassination in American political history.
A different candidate, someone with more of a national profile would be more immune to the above problems. But they have to be a conservative. Otherwise McCain goes into the fall campaign with a divided base.
Odds are McCain loses no matter what. It was not a Republican year. He also still has other problems, the campaign itself was not well run, for example. He did not appear to have "fire in the belly" nor did his supporters, certainly not when compared to the almost religious devotion of some of Obama's supporters, and he treated Obama with kid gloves. Not to mention the complete mishandling of the banking crisis by "suspending" his campaign and then getting sidelined in Washington.
One candidate to avoid would have been Joe Lieberman, apparently McCains first choice. While he had some advantages, solid on foreign policy, close friend of McCain, and almost immune to criticism** because he had been the Democrats own candidate only 8 years earlier. He had the severe problems of not being a Republican and being fairly liberal on domestic issues, basically making him a non-starter.
* Worse than Quayle or Bork, by far.
** Though watching Democrats attack Lieberman and then go through contortions trying to explain why he wasn't bad 8 years before would have been very amusing.