Mac OS X never got a virus, so it is basically the same for OS X on the iPhone (of course if you jailbreak it...then that's different).
Keep in mind that this does not mean that OS X is immune to all forms of malicious programs.
Just the other day apple released patches for 40 security issues in OS X. There have also been Worms seen in the wild.
As good a job as Apple has done in security, one must still be cautious! One of the main reasons Apple has enjoyed such a long period of security bliss is because of the simple fact that Apple computers have always existed in small numbers... making them an unattractive target for hackers.
As Apple gains in popularity, and I expect major gains over the next five years, Apple will undoubtedly see the same number to attacks as other operating systems.
Bottom line: Enjoy it while you can!