The term spyware refers to a broad category of malicious software designed to take partial or full control of a computer's operation without the consent or knowledge of the machine's owner or legitimate user. While the terms sounds like it describes some type of software which "spies" on the user, it has come to refer more broadly to software that controls the computer's operation for the benefit of someone else.
Spyware differs from viruses or worms in that it does not usually try to spread itself, nor have a highly malicious effect. A virus may erase a hard drive and a worm may allow anyone to access all of your files. Spyware however, it much more likely to watch your surfing habits, or serve up specific ads based on the pages you browse.
The goal of spyware is to gain use of infected computers for commercial gain. Typically, once you are infected a spyware program may deliver unsolicited pop-up advertisements; steal personal information (including financial information such as credit card number or other banking information); monitor Web-browsing activity for marketing purposes; or even use your computer to send spam or advertisements to another user!
If your system is running Microsoft Windows as its operating-system, you run a much greater risk of being infected than if you were using Linux or Max OS X. Additionally, Internet Explorer is much more susceptible than alternate and much more secure browsers such as Firefox.
Quite often, semi-legitimate programs may install spyware as they install their main program. This is especially common with file sharing and peer to peer applications. When you are installing applications such as these, you should be extremely careful and look for open source, non ad supported options whenever possible.
Once a spyware program has been installed, it is frequently very hard to get rid of. They make sure that they stay no matter what, offing no or a misleading uninstall option, and even making backups of themselves to auto- reinstall if you succeed!
There are many programs and websites dedicated to cleaning your computer if you've become infected. As with anything though, an ounce of prevention will go a long way. Be careful what you install and you should be able to avoid all but the most sneaky spyware programs.
If however it's already too late for prevention -- I suggest you visit some of the more popular Anti-spyware and Anti-virus websites and learn what you can do about your infection.