One of the points in the first book is that after several hundred years, they still don't understand how the ecology of Dune works.

There are hints that Dune was once a thriving jungle world, before the sand trout encapsulated all the water deep below the surface. So there's plenty of organic matter, and water, and sunlight, to support the sandworm lifecycle.