Many believe that Mac OS and Linux not having virus is a myth or it's because less people use it or whatever reason they make up. The bottom line is that these operating system are simply more secure than Windows. Since Windows dominates 90% of the market it seems like viruses are a normal thing to happen on a computer. The good news is that there is a way out of this.
For everybody to get the idea without using technical explanations let's just make a comparison. Microsoft systems are like a house with so many open windows that there are almost no walls. Everybody can get into the house almost as if they were still in the street. To protect from being hacked you install an anti-virus that is like a body-guard that will stay there watching your stuff. Every time someone picks something up the bodyguard will ask you if the intentions of this person are good or bad. Anti-virus are not only expensive, they are also taking up resources from your computer making it slower and, even worse, that they are not always accurate.
On UNIX-like systems such as Mac OS or Linux the house has walls and locked doors. Whoever want to get in or out must have a key. The precious things are locked up in a safe and hidden in the basement so that even with a key you don't necessarily have access to important things unless you know where they are.
To understand how this is possible it is interesting to know a little bit about the early history of computer software. The difference in the security of these systems is mainly due to historical reasons. Microsoft started to build on a weak basis and their security improvements are merely patches to cover the holes. On the Unix-like systems it is structurally harder to break in. You will notice for example that on Unix-like systems your normal user account is not the "root" or superuser account. When you want to run a program that can potentially harm your computer, usually things related to the system, you have to use the "sudo" command and type your password to run it. This is not the case in Windows based computers where the user can easily erase a system file by just dragging it to the recycle bin. Another difference is that on Windows every file that you download that has a .exe extension can be executed. On a Unix-like system, downloaded files can only be executed if you grant them permission. Since virus, trojans, worms and other malware need to execute something (and usually do something with your system), they are perfectly comfortable in a Windows environment. On GNU/Linux or Mac OS they have a lot of trouble to replicate and cause harm because of the very architecture of the system.
In this way, Mac OS and Linux are not only less vulnerable to viruses but they are also more resilient in case of attack. Malicious software on these platforms only had limited and harmless effects so far. An added advantage of how these systems are built is that they are much more dummy-proof since the users do not have access to the root of their systems so easily. Does it mean that nobody can harm your computer? Well, security is not an all or none feature that you either have or do not have, it is a measurement of how prone your system is to attacks. It will always be a cops and robbers situation!
Still skeptical? I'm not going to help if I talk about a conspiracy theory but just imagine how much money goes into anti-virus software...