A boat floats because the weight of the water it displaces is less than the weight of the boat itself. When an object is placed in a fluid in gravity, both the fluid and the object are pulled downward, but because the object is displacing the fluid, they are, essentially, competing for the lower position. If the object has more density than the fluid, it will be able to push it out of the way and will sink to the bottom. If not, it will only push its own weight of fluid out of the way, and the rest will float above the surface.
While boats often carry, or are made of, materials denser than water, they are also made with very large empty spaces inside. It is this empty space—filled with air, which is much less dense than water—that allows boats to float. Even though the materials that compose the boat are denser than water, by including the empty spaces, its overall density is much less. This is the same reason that a helium balloon floats in air, despite the fact that rubber is much heavier than air.
This principle for why things float is known as Archimedes principle, named after a famous scholar in ancient Greece.