Very simply, Microsoft sold an operating system to IBM, who in 1982 decided to enter the desktop computer market, dominated at the time by Apple and Atari, amongst others. What Gates did that was utter genius, is retain the right to license the OS to anyone else who wanted to 'clone' the IBM machine.
People point to MS stealing Apple's idea of a desktop GUI as a reason they succeeded and Apple failed, but the fact is that the desktop GUI was unimportant in regard to driving sales until at least 1995 (ten years later). Besides, the Atari ST, Amiga, Acorn Archimedes and many others all offered desktop GUIs similar to the Mac and better than Windows 1.0 throughout the 1980's.
IMO, Apple failed to distinguish itself from the other companies, sold their hardware a too high a price, and from 1992 until 1997, barely moved forward at all.
Microsoft, to their credit, did a great job of ensuring compatible transitions from one generation to another, whilst successfully driving competitors into the ground, not least of all IBM with OS/2.