Ice floats on water because the density of ice (0.917 g cm-3) is less than water (1 gm-3).
Why is ice less dense than water?
The molecules in water are affected by a phenomenon known as hydrogen bonding. The molecule is held together by covalent bonds when two atoms share a pair of electrons. However, the oxygen atom pulls on these negatively-charged electrons much more strongly than the hydrogen atoms can. As a result, the electrons tend to hover closer to the oxygen atom than hydrogen atoms. This leaves the molecule as a whole with a slight negative charge around the oxygen end and a slight positive charge around the hydrogen end. In liquid form, as the molecules move around, hydrogen bonds form and break over and over, and the molecules can slip past each other.