Usually when solids form, atoms get closer together to form something denser. This is why most solids sink in water. But solid water, or ice, is actually less dense. Water molecules form rings when water freezes. All that space makes ice less dense, so it floats. Ice floating on top of a body of water lets the rest of it stay liquid. If ice sank, whole oceans could freeze solid!
adapted from climatekids.nasa.gov