Nintendo selling Rare was possibly one of, if not the, most ingeniously profitable moves in the history of this business.
Even after Microsoft retained full ownership of the company, Nintendo did not cease getting support from them in the form of GBA or DS titles, all of which have been much much more successful than all of their Xbox and 360 games combined. And add to all this that Nintendo no longer had to pay Rare employees or maintain the building they worked in and all that jazz, Microsoft basically paid Nintendo to make a profit.