It’s actually not milk in the strictest sense of the world – milk comes for the mammary glands of mammals — but the worms are passing a nutritious, liquid food from parent to baby.
Adult C. elegans live a short life. Within a few days of reaching sexual maturity, their bodies break down and stop functioning, a process called senescence. Their intestine atrophies into a fatty, yolk-like material and their muscles fragment into pieces. Researchers used to chalk up the appearance of the yolk mass as just a weird thing that happened as the worm aged, like how you pull muscles from standing up wrong. Old nematode bodies hold together enough to make yolk, but degeneration of other parts of the reproductive system eventually inhibit successful egg-laying. (Interestingly, if a fertilized egg is not laid within about 12.5 hours, it hatches inside the worms body, where it then eats and kills its parent.)
The decomposing goo isn't wet garbage after all: it’s worm milk. Post-reproductive mother worms vent the yolk through their vulva and on to their offspring, providing them with a boost of nutrients to support their growth.
What’s more is the worm’s lactation and senescence processes involve some of the same biological machinery (through the insulin/IGF-1 signaling pathway). This suggests that these two processes are closely related — nematodes don't just happen to make yolk as they get old; self-decomposition linked with yolk production evolved to as a way of passing on as much of their energy as possible to their offspring.