To understand how firewalls work, picture your computer as a house. When a computer accesses the Internet, it has to open a connection between itself and the World Wide Web. This is the equivalent of opening a window in your home and walking away from it. Certain types of computer hackers maintain programs that constantly watch for these connections, as each one may provide a route to an unprotected computer. If your window has no screens or bars, it is easy for an unwanted intruder to use this route to come into your home; similarly, an unprotected Internet portal provides an open window for hackers to come in and do whatever they want to your now-vulnerable computer.
A firewall is the computer equivalent of putting bars over your windows. You can still see out easily and get what you want out of the window, but no intruders can come into your house. Just like bars over real windows, however, Windows firewalls cannot protect your computer from everything. For example, if a program, like spyware, was accidentally invited into your computer and you did not catch it, it can open your firewall to let the hacker into your computer anyway. For this reason, you need more than just a firewall to keep your computer secure. It works as part of a team including your antivirus software to protect your computer from unwanted invasions.
Besides software firewalls like Windows Firewall, there are two other types of firewalls used in computers: a hardware firewall, which would be installed into your computer just like a hard drive or video card, and firewall protections built into an Internet router. If you have a wireless router and a Windows Firewall-protected computer, you have effectively two firewalls.