A firewall is a network security tool designed to monitor and control all traffic, incoming and outgoing, on a network based on defined security rules. It can serve as a gateway or barrier to keep a network or specific computer safe from corrupted files or content. Firewalls are created with a set of rules that prevent unauthorized access to the computer or network.
Firewalls are often used at businesses to prevent employees from visiting untrustworthy sites or downloading questionable content in order to keep the network safe from potential hacking.
For personal home use, your router functions as a hardware firewall to prevent unsolicited incoming traffic from reaching the computers and devices in your network.