Firstly, the Linux base is written by a hacker (Linus Torvalds), so he probably has considered security risks a lot better than Microsoft did.
That's a bit naive, really. Linux has evolved from a monolithic kernel OS from a time where the security concerns of modern OSs were simply not realistically threats. In comparison to mainframe OSs it was then remarkably basic, at least from a kernel perspective.
On the other hand, most Windows OSs we're considering evolved from Windows NT which, on the other hand, at least stemmed from a robust kernel design.
Secondly, Linux (in all its variations) doesn't have enough of a market share to be interesting to hackers and virus writers. There's no point in writing a virus targeted at 1.5% of the computers when the same effort can get you access to more than 80%, including most government computers.
This is probably more key - I'm far from convinced that the normal bandwagons spouted about security and stability are as much about prevalence, ISV involvement, and exploitation than actual inherent attributes.