What do earthworms actually do for soil?
Rather more than aerate it. Worms are physical engineers, chemical processors and distributors of organic matter, and the effects compound over years.
The three groups, which do different jobs. This distinction explains a great deal:
Surface-dwellers live in leaf litter and compost heaps, never really enter mineral soil, and break down organic matter fast. These are the ones in your compost bin.
Topsoil worms burrow horizontally through the upper layers, mixing organic matter into mineral soil continuously.
Deep burrowers, the large ones, make permanent vertical burrows metres deep, coming to the surface at night to pull leaves down into them. Their burrows are the ones that matter most for drainage and for root penetration, and they are destroyed by ploughing, which is a central argument for no-dig and reduced-tillage systems.
What their activity produces:
Casts — worm excreta — which are significantly richer in available nitrogen, phosphorus, potassium and calcium than the surrounding soil, because passage through the gut and its microbial population transforms the material.
Stable aggregates. Casts and mucus bind soil particles into crumbs that resist being washed apart, which is what good soil structure physically is.
Drainage and aeration, through burrows that carry water down rapidly — a worm-rich soil absorbs heavy rain far better, which matters for flooding as well as for plants.
Incorporation of organic matter, moving surface material down where roots can reach it.
Habitat for roots and microbes, since burrow linings are biologically rich.
Darwin spent decades on this, and his last book argued that worms had passed the whole of the soil through their bodies repeatedly and buried Roman remains — a claim that was mocked and turned out to be correct.
How to encourage them: add organic matter, mulch the surface, dig less, avoid compaction, and avoid unnecessary chemicals. Worm numbers are a decent proxy for soil health and are easy to count yourself.