.NET Core is a great example. Microsoft directly benefits from gaining market share among developers — it helps them sell Azure, etc. Open sourcing it was absolutely necessary to remain competitive. They did it because it’s the right business decision.