According to Wikipedia, a firewall acts as a barrier between a trusted network and an untrusted network. It is a type of network security system that monitors the incoming and outgoing traffic on a network based on predetermined safety rules that are in place, that prevents an unauthorized entry from a non-trusted source.
There are 2 forms of Firewall in use and they are Hardware (Physically present) and Software (Virtual). It's recommended having both. A software firewall is a program which is installed in every computer of the organization or an individual computer which regulates the traffic through port numbers and applications, while a physical firewall acts as physical equipment installed between your network and gateway.
If you want to know more about the Firewall and similar cybersecurity measures took up to protect and secure the network systems around the world check out our cyber security course and ethical hacking course too.