1. Update Update Update!
Your operating system (Windows or MacOS for most people), Java, Adobe Flash, and your web browser (Edge, Internet Explorer, Google Chrome, Firefox, etc) are often the ticket for a virus to get onto your computer. Updates often fix security flaws that have been found in your software. Malware authors then reverse engineer these updates and create a virus, ransomware, or advertising software that is able to use your old software to install on your computer without your knowledge. By keeping software updated you are avoiding being a part of the large percentage of people who do not regularly update their software and are targeted by virus writers.
2. Install AdBlockPlus and Remove Unnecessary Plugins