MS paid that much for GitHub because it was a bargain. Their market cap is about $770 billion, after the acquisition announcement they’re stock is up 2%, which paid for the acquisition and then some. And the $7.5b given to Github wasn’t in cash, it was completely done in MSFT shares.
In return they get access to millions of developers who’ve never tried .NET, Windows, or Azure. Even just converting a small fraction of those is billions in added revenue.