Microsoft was born as a developer tooling company that accidentally ended up in OSes because early OSes were developer tools. (BASIC was the first OS for the IBM PC, just as it was for the Commodore 64.) Microsoft's strategy to buy GitHub is clearly a developer tooling choice, nothing to do with the failure in phones. Microsoft's original strategy was always to transcend hardware (early Microsoft products were notoriously cross-platform in an age where cross-platform was much harder), they've always been a software company first (hence their name), and a hardware company begrudgingly.