The fool-proof way is not connect to Internet, and not use diskettes or USB-sticks that have been used in other computers. But that's somewhat impractical for most users.
Then they install an antivirus program, a realtime antimalware program (or the free run-once-in-awhile version), don't install Java, don't install Flash, use strong passwords, never use P2P file sharing programs, never click on links in an e-mail, only visit well-known reputable sites in your browser, donwload software your want to install from ninite.com and only work in an adminstrator Windows account if necessary.
All of this helps. But it's no guarantee.
Kees
How to protect system from Spyware and viruses

Chowhound
Comic Vine
GameFAQs
GameSpot
Giant Bomb
TechRepublic