Water has a special characteristic since its composition of oxygen and hydrogen allows hydrogen bonds to form between water molecules. When the water freezes, the molecules, due to the hydrogen bonds, line up, this causes a greater repulsion between the water molecules and they move away from each other. Moving away increases the volume of the ice, increasing the volume and maintaining the mass decreases the density.
In contrast, when water is liquid, the molecules are not aligned and hydrogen bonding causes the water molecules to bond together, making it difficult for them to move far enough apart to form a gas at room temperature. That is, its boiling temperature increases and a higher temperature is needed to obtain water in gas form.
So for both phenomena, the explanation is the hydrogen bonds that form the water molecules. Depending on the orientation of the molecules, these may or may not favor the bond between the water molecules.