Your in the wrong section for this kind of question, but heres an answer anyway.
A firewall is a program that detects incoming and outgoing connections from your PC (whether it be too/from the internet or LAN) and compares it to a list of acceptable connections. If it doesn't come up positive, it blocks the connection. This is to prevent people/files from entering your PC or stopping unauthorized programs (such as malware) from communicating data from the computer to the internet.
A firewall only deals with incoming/outgoing connections, once a virus enters the system, it wont attempt to destroy or contain it. That's where Anti-Virus programs come in.