Why is the Unix operating system virus free?

First of all, Unix (and even Linux) is NOT virus free. Although rare, there are viruses for such systems.

One of the primary reasons that Unix / Linux do not get as many viruses is that the ability of different users is limited. Non-technical users will be restricted in their ability to install, run, or modify software. More experienced users will usually be given more privileges. Without inexperienced users installing software at a whim, over 90 % of the threat of viruses and malware is removed.

Linux is even further protected against viruses because Linux is by nature a heterogeneous platform. To be effective, the program would have to be capable of affecting multiple versions of the kernel, and use exploits in a variety of programs.