The common thinking is that C# & .NET was a ripoff of Sun Java because of the "write once run anywhere" threat. That's sort of true but missing some nuance.
I'm not a MS insider but here's my understanding of what happened. We have to separate the C# language from the CLR runtime. In the 1990s, Microsoft was already researching how to enhance and extend the COM interoperability model. (Otherwise known as "how do we get multiple programming languages to talk to each other?")
Based on some old interviews with Don Box, instead of this work being productized and released as "COM+ version 3" or whatever, it morphed into the CLR. This was a natural evolution that would have happened even without Sun's JVM threat.
C# the language, on the other hand, was a more direct response to Java the language since Microsoft's J++ (Java clone) was abandoned because of Sun's lawsuit.
As for .NET, it's interesting that Microsoft always had this large internal group of programmers (mostly Windows kernel and Office teams) that didn't fully buy into the .NET vision. On the other hand, Bill Gates himself was a big believer in it. My pet theory is that since Bill Gates programmed in BASIC in the 1970s and not in low-level C/C++/assembly, he had a natural affinity for the vision of high-level C# & .NET being pervasive throughout Windows. Even with Bill's support, there was always an ongoing internal tension between the C++ vs the NET framework camps. (On a related note, it seems like Apple's internal programmers are more happily embracing Swift over Objective-C to a greater degree than Microsoft's internal adoption of C# over C++.)
.NET is still very popular but it definitely did not fulfill the more ambitious dreams that Bill Gates had for it.
(On a related note, I also wrote an old comment about the decline of .NET's WPF and its limited adoption: https://news.ycombinator.com/item?id=14098832)
 Was MS Technical Fellow and author of 1998 COM book: https://www.amazon.com/Essential-COM-Don-Box/dp/0201634465