People often say that Macs are more secure than say Windows. Which is why many Mac users don't have antiviruses. But why is this? Is it because of the need for a password for `sudo` commands, like changing system files?

But then couldn't the hacker just steal the password also in his virus - how hard could that be? Why is Mac more secure than Windows?