macOS built-in security feature Firewall is designed to safeguard your Mac with an extra layer of shield.
When its active and set up, unauthorized applications and programs are blocked to accept incoming connections.
Though you have the desired flexibility to allow specific apps to accept incoming connection even if its turned on.
In this in-depth tutorial, we will show you how to enable and use the Firewall on Mac.
Customize and Firewall on Mac Like a Pro
There you have it!
Considering how pivotal this security feature is, I would recommend you keep it always enabled.