I'm just starting with the original novel but have an interest in desert planets so bear with me please.
Per Wikipedia:
It seems the sandworms are responsible for Arrakis becoming a desert planet:
The sandtrout [...] was introduced here from some other place. This was a wet planet then. They proliferated beyond the capability of existing ecosystems to deal with them. Sandtrout encysted the available free water, made this a desert planet [...] and they did it to survive. In a planet sufficiently dry, they could move to their sandworm phase.
OK so the sandworms are responsible for the water being under ground.
And then another explanation:
The non-canon Dune Encyclopedia (1984) theorizes that the depletion of the oceans (the primary result of which was desertification) was probably caused by the impact or near miss of a comet or other quasi-planetary body. This event caused the loss of much of the atmosphere of Arrakis, allowing most of the oxygen and water to escape into space. This is thought to have occurred approximately 50 million years before the Imperium's creation. This catastrophic loss of oxygen led to the extinction of nearly all native fauna and then therefore the flora.
OK I get that. But now the sandworms are back:
The Encyclopedia also explains that one of the few forms to survive were tiny worms of the phylum Protochordata. One of these forms was Shaihuludata, a genus of anaerobic burrowing worm that was the basal species from which the giant sandworms (Geonemotodium arraknis or Shaihuludata gigantica) evolved. Rather than sandworm creating desert, it was desert that created sandworm. The mass extinction of all of its predators and competitors for food allowed the animal, in a manner somewhat analogous to the evolution of unique faunal forms on isolated Terran islands, to take the evolutionary path that would not only re-oxygenate the Arrakeen atmosphere, but also create the spice melange with all of its immense consequences for humanity.
OK now instead of killing all life on the planet they re-oxygenated the atmosphere and (seemingly) brought biological life forms back at the same time. Again, how would they have made that happen without water?