That's just not true. Android and desktop OSX are counter-examples. It is security measures like sandboxing of apps that prevent mobile devices from needing anti-virus software.
On desktop Windows, programs used to have unfettered access to the filesystem, including Windows DLLs that were major parts of the OS. Looking back, it actually seems incredible that it wasn't more of a disaster than it was.