A ship, or any other object that floats, doesn't sink because it's able to displace an amount of water equal to its weight before it becomes submerged. For example, a ship that weighs 1,000 pounds sinks until 1,000 pounds of water are displaced, and then it floats.
Ships are able to displace enough water to float because they are less dense than water. A ship's density is determined by both the material used to build it, such as wood or steel, and the open spaces within the ship. Because air is so much less dense than water, the combination of steel or wood and air is much less dense than the water below it. In fact, air is so much lighter than water that very little of a boat has to become submerged for it to displace enough water to float. Because of this principle, ships can be built out of materials such as steel that would sink if they were in a solid form.
Ships float because of the upward pressure of the water beneath the boat. This water pressure pushes up on each square inch of the submerged part of the ship and allows it to float on the water's surface.