Well, both viruses and trojans is programs / line of codes that can potentially harm both you and your computer. They can steal your internet passwords, files on your computer, credit card number etc.
The biggest difference is that a trojan is a program that covertly (secretly) enters your computer, send something on or downloads something without your knowledge.
Spyware are programs that basically spies on you. It finds your passwords, sites you have visited etc.
You are right in the fact that you don't want them.
These things come from websites that have a hidden line of code that makes the virus/trojan/spyware (hosted somewhere else most often) download to your computer and begin to do what they do (described above).
One of the best anti-spyware programs (programs that removes spyware or block the download) for beginners is Windows Defender. The program is made by Microsoft and can be found here:
http://www.microsoft.com
Check below the picture to the left and you will find "Windows Defender" Beta 2. Click on it, and further installation information will be displayed.
Let me know if there is anything else you want to know :)
-------
"The larger the island of knowledge, the longer the
shoreline of wonder" (Ralph W. Sockman)