At the basis of these terms lies the fact that most people on the planet are right handed (around 80%) so it stands to reason that in the early days of sailing a boat captain would steer with his right hand. To that end, steering oars were attached to the right side of the ship towards the back. The Old Norse word for “rudder” (in this case referring to the steering oar) is “styri” and “board” has long referred to the side of a ship (probably due to the fact that ships were built with wooden boards). Therefore “starboard” became synonymous with the right side of a ship.
Because a ship’s steering oar is attached to the right side of the ship then clearly one would not want to dock on that side for fear of damaging the oar therefore sailors would dock on the left side when in port. The left side of the ship thereby became known as the “port” side as that was the docking side when in port.