What is a port?
Port number is an application or process-specific handle serving a network connection on a given network address.
As we already know, each device (PC, laptop, mobile phone, etc.) in the network has its own IP address. It is unique for a specific device and gives an ability to establish a network communication. By the way, on this device could be run several network applications. Port numbers provide an ability to identify a specific network application running on the device.
For example, on some Internet server could be run at the same time such applications as a web server, mail server and FTP server. All them are network applications. The Internet server itself has an IP address, but if you had tried to establish a connection with the server based only on IP, there would be an ambiguous choice of which application you have to select to send or retrieve the data.
Port numbers resolve this problem. So, to establish a connection to a web-server running on some machine in the Internet you will need to know an IP address of the machine and port number of an application (or process) running on this machine. For the same time, the other side, which initiates the connection, must also provide its IP address and port number of the application or process which will serve a connection, to let the server know where the response data should be sent.
Generally port number is represented as 16 bits unsigned integer value and could vary from 0 to 65535 value (which gives 65536 available port numbers).
IANA (Internet Assigned Numbers Authority), which is responsible for Internet protocol resources, defined a commonly used ports for well-known Internet services and reserved for their needs numbers from 0 to 1023 (totally 1024 port numbers).
Thus, all web servers by default are configured to be running on port 80, most of the secured web servers running on the port 443, Domain Name System (DNS) running on the port 53, etc. Here, you can find a full list of reserved a registered by IANA ports.
As far, as behind the port number running software, and most of software could have bugs or security holes (in other words, could be exploitable). It means that for security reasons it is better controlling all the ports, opened at a specific device. Also, it is good to manage all the connections (incoming and outgoing).
For example, to prevent network attack to your home PC it's recommended closing all the ports with a firewall application and open some of them only when you need to use them (for example, when you want to create a game server, etc.).