well basically, as to my understanding, ports are like doors. the more doors you have, the most likely someone may enter thru that door either wanted or unwanted guess. Ports are opennings that allow packets to enter and leave based on their process. There are ports that are very important and there are those that are mostly compromise. These are the ports that should be given attention to prevent any form of attack that could take place.
If you have a firewall, you can open/close ports to allow/disallow certain types of services that uses those port for access. In this way, you are able to secure your box (or network) from any attack from the outside world.