As mentioned, Apples aren't theoretically immune to viruses! However, also as mentioned, Apples running OS X have, at present, no known viruses out in the wild that pose any significant threat. If you own an Apple running OS X, buying and installing virus protection software is actually a cure that is worse than the disease. There is an argument for it--being a good citizen of the net and all that--but I don't have any virus protection software running on my Mac.
As for Apples not having viruses simply because there are so few of them, well, that argument really doesn't hold as much water as everyone thinks it does, in my opinion. OS X Macs are running an open BSD UNIX kernel. That's the heart of the operating system, and it's a time tested and rugged kernel with pre-emptive multi-tasking. Most, if not ALL big sites on the net are running a UNIX operating system of some sort or another according to what I've read and been told by people in the know.
So, think about it: if you were a hacker, which computer would you want to hack, one of PayPal's or Joe Blow from Idaho's personal computer? I think the answer is obvious. And so the vast majority of targets that hold appeal to hackers are NOT PC's. And yet you don't hear about all sorts of UNIX viruses, do you?
Except the argument doesn't end there. The thing is that hackers use PC's to help them hack into big UNIX servers. Why? Well, yes, there are a lot more PC's out there, and so if you develope code to hack a PC running a certain version of Windows, you have a lot of PC's out there to use your code on. So, yes, Apples are less appealing because there are fewer of them.
But, that's not really the whole story--not by a long shot. First of all, everything on a Mac comes locked down from the get-go. Right out of the box the root account is disabled and all the share settings are OFF. This is in marked contrast to many of the Windows versions which had to be locked down manually, which wouldn't be done by someone with little or no computer savvy.
Next, the UNIX plumbing of a Mac running OS X is significantly harder to penetrate. That's part of the reason why so many servers run some kind of UNIX--or so I have read. This is why hackers need a couple dozen or even hundreds of PC's that they can command remotely to help them hack a UNIX box.
And finally, Apple is noticeably more fastidious in keeping their code tight. The classic hack is a buffer over-run. Suppose an OS is looking for an input 8 bytes long. Fine. Well and good. If everything were as it should be, the input would only be 8 bytes long. But if someone intentionally shoves 108 bytes down its throat, and IF there is nothing in the code to check the length of the input and throw out anything over 8 bytes, then the extra 100 bytes gets written into the 100 memory spaces following the space allocated for the input. If you work it just right, they can overwrite the buffer for the next command input, or send the pointer off to someplace else, where a command gets executed by the OS that was NOT intented. It's tedious and difficult and requires an intimate knowledge of the OS and CPU machine code, but this is what writing a virus is all about.
Anyway, point is that Apple is careful about buffer overflows and other such security weaknesses.
But more than that, the pre-emptive multi-tasking UNIX kernel is a more difficult beast to deal with than a simple multi-tasking kernel. OS X may look and feel like a regular old friendly windows-type OS, and the GUI certainly is that, but under the hood it's a different story. It's pure UNIX. You can easily open up a shell and start typing UNIX commands directly. I do it all the time to access my server space and do file transfers.
Does this make Macs "better" than PC's? Oh, who the H**L knows! The whole Mac vs. PC argument is incredibly fruitless and annoying, isn't it? They are what they are and some people will prefer macs and some will prefer PC's.
I can tell you that Macs seem to have a much longer "half-life". Here at work, in the control room of the accelerator, there is a G3 Mac running OS X version 10.4, and it performs about as well as the year old PC I have in my office. A G3. That's THREE GENERATIONS old. Intel-G5-G4-G3. And it's still working. It's like 8 years old or something! It's had a memory upgrade, and a hard-drive upgrade, but other than that, it's the same computer as when it was purchased. To my mind that's pretty frigging incredible!
Of course, Macs cost more! There are a lot of pros and cons, as always, and I think there are very good reasons why a person would chose one type over the other, but for my money, for my personal uses, the OS X Macs are the better choice. I've had my G4 over two years now, and it has never once locked up. It hasn't crashed once. And I'm still often amazed to discover some new little thing or feature or capability that reaffirms how powerful and amazing OS X is. I love OS X. I tolerate Windows. And I use both all the time.