Follow da money
Nokia was 80% of the sales of Windows Phone. But Nokia really wanted to go Android with the new Lumia, so MS risked losing that and their share of the smart phone market, so they had to buy Nokia; they didn't have to screw it up so royally.
Nokia reported a 17 percent drop in full-year net sales in 2013 to 12.7 billion euros ($17.3 billion). However, net sales came in at 3.5 billion euros in the fourth quarter, up 18 percent on the same quarter a year before. Profits were made by year end ($585 million profit in Q4 on $10.73 billion in revenue), coming after 18 months of loss- overall sales figures had been declining since 2011.
Microsoft had been have a rough time aboard the good ship Windows (inc Mobile), with leaks everywhere below the sales water line. Nokia's raft was seriously burnt on sales\ profits, and alas, they made the choice to jump ship to M$ completely.