The first and foremost reason why people get their computers infected is because they were using outdated, obsolete and older software. Such older software usually has some known vulnerabilities that are often used by hackers and malicious programs. Even a single outdated program used by you can put the whole system at risk of being attacked or infected with nefarious malware. For example, if you use and older version of JRE (Java Runtime Environment) then your PC can easily become the target of drive-by download attacks (In these attacks, all you have to do is visit a compromised website which automatically installs malicious programs in your PC without your knowledge).
The first line of defense against modern malicious software is to keep your PC updates with all the latest software installed. For example, if you use Mozilla Firefox, then always use the latest version. And it is not very difficult to keep yourself up-to-date. All you have to do is switch the settings of all these programs to automatically update themselves. Most of the programs these days come with the ability to automatically check and install the new updates as they become available.
If you are not sure whether you are using the latest programs, browser plugins etc., then you can make use of a freeware called WIGI which is acronym for Why I Got Infected. The simple tool checks your operating system (Windows), web browsers, JRE and Adobe Flash to see if you are using the latest versions. It displays the programs in green color if the latest version is installed, otherwise the programs are shown in red color.
You can double-click on the update URL to download the latest version of the outdated components or programs from within the WIGI interface. Perhaps in the future they will also check for more popular programs, plugins and other components for the new versions, for example, .NET Framework, Adobe PDF Reader and Microsoft Silverlight.
You can download WIGI from http://www.adlice.com/software/wigi/.