Because, basically, it is less dense than the surrounding water.
A piece of ice displaces water when immersed in water and receives a buoyant force proportional to the weight of the displaced liquid, a phenomenon known as Archimedes’ Principle.
Consider the example of the iceberg:
Density of ice is
Density of water is
Buoyant force=weight (1)
Buoyant force=weight of displaced liquid (water)
Weight= weight of iceberg
mass=density x volume
weight=mass x g
weight water displaced=weight iceberg
You get that:
So, 89% of the iceberg is submerged!
If the two substances had equal densities it would still float but with no visible external part:
Indeed, ice floats in water because it's less dense than water.
I would like to add a chemistry-oriented explanation to Gió's excellent physics-oriented explanation; more specifically I would like to show you why ice is less dense than water.
In liquid water, water molecules are constantly on the move, always bumping and colliding with other water molecules. This implies that the intermolecular bonds that exists between the water molecules, the most important to mention here being the hydrogen bonds, are being broken and reformed constantly.
When temperature starts to decrease, the average kinetic energy of the water molecules starts to decrease as well. This means that, on average, a molecule experinces less interaction with other water molecules.
Everything slows down a bit. This implies that the hydrogen bonds are not being broken at the same rate as they are being formed. Two water molecules are in contact with each other for longer periods of time.
If the temperature continues to drop, the strength of the hydrogen bonds will exceed the average kinetic energy of the molecules. This means that the hydrogen bonds will no longer be broken
As a result, a vast network of water molecules is formed. As you can see, there is a considerably amount of space between water molecules in the solid form.
Since you cannot pack as many water molecules per unit of volume as you can in liquid water, ice will have a lower density.
From here, like Gió showed in his answer, it's just a matter of buoyancy and of Archimedes' Principle.