As the name implies it is a wall between the host ,that is your computer and external resources.
When someone on the Internet or a network tries to connect to your computer, it is called an "unsolicited request." When your computer gets an unsolicited request, a Firewall blocks the connection.
A firewall helps to keep your computer more secure and prevents your system from being hacked.
However a firewall is not equal to an antivirus program ,it has no surety that it can block viruses.
You can configure your firewall in the way you want and then work on the Internet , however when a firewall blocks a connection you can always override it.