Context. Millimetric observations have measured high degrees of molecular deuteration in several species seen around low-mass protostars. The Herschel Space Telescope, launched in 2009, is now providing new measures of the deuterium fractionation of water, the main constituent of interstellar ices. Aims. We aim at theoretically studying the formation and the deuteration of water, which is believed to be formed on interstellar grain surfaces in molecular clouds. Methods. We used our gas-grain astrochemical model GRAINOBLE, which considers the multilayer formation of interstellar ices. We varied several input parameters to study their impact on water deuteration. We included the treatment of ortho- and para-states of key species, including H2, which affects the deuterium fractionation of all molecules. The model also includes relevant laboratory and theoretical works on the water formation and deuteration on grain surfaces. In particular, we computed the transmission probabilities of surface reactions using the Eckart model, and we considered ice photodissociation following molecular dynamics simulations. Results. The use of a multilayer approach allowed us to study the influence of various parameters on the abundance and the deuteration of water. Deuteration of water is found to be very sensitive to the ortho-to-para ratio of H2 and to the total density, but it also depends on the gas/grain temperatures and the visual extinction of the cloud. Since the deuteration is very sensitive to the physical conditions, the comparison with sub-millimetric observation towards the low-mass protostar IRAS 16293 allows us to suggest that water ice is formed together with CO2 in molecular clouds with limited density, whilst formaldehyde and methanol are mainly formed in a later phase, where the condensation becomes denser and colder.