Alonso wanted to move back to Spain as early as 2007 (according to Brian Reade). The summer of 2008, Xabi hadn't been up to his standard for a couple of seasons and Barry had probably been better than him and was also a more versatile option. Being tied in with the Inter Milan incident, Rafa decided, quite logically, Barry was a better option. The deal didn't come off and then Xabi put in a fantastic season in 08/09 and then decided to make a transfer request.
Looking back, it was a mistake by Rafa but it's easy to see why it was made. Barry was playing better than Xabi in 2008.