The purchase of github doesn't make immediate financial sense to me. This article posted a reason - to stave off Windows decline. While it is plausible, I still don't see it.
The reason? Simple. Developer mindshare. Microsoft lost it with Ballmer, and is getting it back under Satya. Ultimately Microsoft's success has always stemmed from providing platforms that support developers, and in turn they build great products people will pay for. And that drives Microsoft revenues, be it the OS, or nowadays, SaaS PaaS and IaaS (and OS).
When I think of Ballmer, the first word that comes mind is "developers" (it's also the second... and the third...)