Use an Anti-Virus program.
I recommend is Avast free.
Use a firewall program.
I recommend Comodo firewall which is free.
Use Anti-Spyware software.
Spybot is a good free Anti-Spyware program.
Update your security software, OS and scan your computer weekly for viruses, spyware, and adware.
Download and buy software and files from trusted sites you know are virus free like download.com or sourceforge.net
Don’t visit websites that seem illegal since they know you would not report them for spreading viruses since they don’t want people to know they downloaded illegal content, so if there is a virus, malware on the website. It is less likely to be reported.