Everything in Windows is centred around its 'registry', so all of the programs on a Windows computer are effectively linked together. That makes it relatively easy for a virus-writer to attack the whole system through a flaw in just one program.
Other operating systems don't have a 'registry' (or not, at least, of the same type that Windows uses). That means that their programs are 'sandboxed', so that something dodgy in one program can't affect the rest of the computer.
So it's far harder to virus writers to attack Macs, or systems running on Linux, Android or iOS, than it is for them to attack Windows. (In the early days of home computers, Microsoft only won the battle to become the leading provider of an operating system through better marketing. The operating systems offered by other computer firms, such as Atari, were actually vastly better than Windows).
Windows has always been an extremely poor operating system and, because of its use a registry, always will be.