This has been answered a million times, and always ends up the same. Some people say it's lack of marketshare, some say it's that Macs are built safer, and the rest of us say a little of both. Then someone comes in saying they could write one if they felt like it, but don't. Truth is, there were viruses for OS 9, and it had an even smaller market than Apple does now. Plus far less exposure in the media. Same with Linux. Any script kiddie can write a Windows virus, especially in IE especially because it's so unsecure and also used by a lot more people and businesses. Neither of which tend to update as much as they should. If someone could write a virus for OS X that actually causes harm in the wild, they'd be famous. No one has yet. Someone came close last year, but it didn't infect too many people because it didn't spread. And you had to manually d/l something first. Just a lot of proof of concepts out there mostly. But it is possible, so we can't be too smug.
But we are a lot safer, and though obscurity is a small part of it, security is a larger part. And actually the obscurity might wind up hurting us. As I said, the first guy to actually write a real virus that actually worked for the Mac would be famous among his peers, many of whom hate Apple.