The reason that water expands when freezing is that when it is near its freezing temp (below 4°C), the hydrogen bonds between water molecules become stronger. Because the bonds between water molecules are stronger, they are more unlikely to break and re-form like when in its liquid state. In its liquid state, water molecules are constantly moving (forming and breaking hydrogen bonds) resulting in less expansion. The water molecules therefore are more refined and are arranged in a manner that forms a six-sided crystal, which makes the ice less dense than the liquid water. When water freezes, it expands by approximately 9%.
When water molecules are in the liquid state, hydrogen bonds are continuously being formed and reformed in a disordered fashion. The average amount of H-bonds a water molecule has at 25°C is 3.4 bonds. During freezing, water molecules lose energy and do not vibrate or move around as vigorously. This allows more stable hydrogen-bonds to form between water molecules, as there is less energy to break the bonds. Because of the crystal lattice structure imposed on water molecules once the freezing point is reached, the average H-bonds per water molecule is much closer to its maximum, 4 bonds. The orderly, crystalline way in which the hydrogen-bonds form causes density to decrease because each water molecule is held away from its neighbors at a distance equal to the length of the hydrogen bonds. Thus water expands as it freezes, and ice floats atop water. This property is crucial to life as we know it. Ice sheets on the surface of the ocean insulate the water beneath and allow organisms live in polar regions of the world, and also prevents oceans from freezing solid.