The maximum density of water is at 4°C as there are two opposite effects that are in balance.
When the water is in the form of ice, there is a lot of empty space in the crystal lattice. This structure starts to collapse when the ice starts to melt. The water molecules move further apart when the temperature increases as the density decrease.
At 0°C, water contains ice-clusters which are free to move. There are empty spaces in these clusters making the density to reduce.
When the water starts to cool, there is a decrease in warm water temperature, resulting in an increase in density. At 4°C, the clusters start to form resulting in a maximum density of water.