From what I understand it is actually a by-product of their attempt to break Java compatibility.
Microsoft bought a Java license from Oracle and added support for the language to their IDE.
However, they started to add features to the language that were not part of the standard and not present on other operating systems.
By creating templates that use these features, they caused programs made using their IDE unable to run on anything other than Windows.
According to Oracle, this was copyright infringement. They claimed Microsoft called their language Java, even though it was not Java. They sued Microsoft and won the case.
As a result, Microsoft had to change the name of their language. This became J++.
This was later used as the base for C#.
I assume they wanted to make it sound as if it was a successor to C or C++,
like how many people think C++ is the successor to C.
The reason they continued with a VM was likely for Windows CE compatibility.
Windows CE is still commonly used in factories.