A firewall is like a doorman who keeps unwanted people out of a building.
Imagine that you are at home, using your laptop, and you want to use a computing service that's at the University. When your laptop tries to contact the University computer, its network traffic has to cross the internet, then go through the University's firewall computers.
The job of these firewall computers is to allow through only legitimate, harmless-looking traffic. Unwanted network traffic is not passed through, so it never arrives at the University computers.