There are different types of soils which differ, among other things, by their porosity. While some soils are very compact, such as clay, and do not allow water or gas to pass (and therefore no oxygen to breathe), others are more permeable. The soils in which earthworms live are permeable enough to allow air (and water) to seep between the grains. In addition, earthworms dig galleries by “eating” the earth to feed themselves (they sort out what is edible in their digestive tract before throwing the earth behind them). They therefore actively participate in the aeration and hydration of the soil, which makes them valuable aids for good soil health.
So air circulates over the skin of the earthworm. But it has neither lungs (like us), nor gills (like fish or sea worms). He breathes through the skin! Over a large part of her body, she is extremely thin. This is called skin respiration. However, the skin must remain moist so that the oxygen in the air mixes and can pass (we say to diffuse) through the skin. The earthworm therefore secretes mucus which makes it viscous to the touch. And in addition it helps it to slide in its galleries.