The water molecules in ice are present in a crystal lattice that has lot of empty space.
(Image to be added soon)
When ice melts to liquid water density of the liquid increases as the structure collapses. At temperatures well above freezing, the molecules move faster and get further apart. The density decreases as temperature increases. At temperatures near 0 °C, the water still contains many ice-like clusters. These clusters are free to move relative to each other, so water is still liquid. The clusters still have empty spaces, so they decrease the density of the liquid. The molecules of the water are closer together, and this increases the density of the liquid. As the temperature of warm water decreases, the water molecules slow down and the density increases. At 4 °C, the clusters start forming. The molecules are still slowing down and coming closer together, but the formation of clusters makes the molecules be further apart. Cluster formation is the bigger effect, so the density starts to decrease. Thus, the density of water is a maximum at 4 °C.