The molecules of most elements are more compact in their solid form than they are in their liquid state, but water is different. As you may know, each water molecule is made up of one oxygen atom with two hydrogen atoms attached.
The hydrogen atoms in water have a positive charge and cause the water molecules to be attracted to one another. This attraction forces water to form a net of crystals with lots of gaps in it as it freezes. The crystal net structure takes up more space than liquid water and so water expands as it turns to ice.