The way I see it, Rafa blundered into it. By his standards, Alonso had a poor season in 2007/08, not helped by injuries. Instead of being supportive, Rafa started sniffing around after Gareth Barry. I think Alonso was deeply offended that Rafa was willing to discard him so casually, and it was then that, as a proud Spaniard, he made up his mind to go somewhere he would be more appreciated.
Rafa botched his attempt to sign Barry, and Alonso therefore stayed for another season, 2008/09. I think it's a great credit to the player that it was his best-ever season for Liverpool at a time when he could have just wound down before leaving for Real Madrid.