Convential wisdom is that earthworms escape to the surface to stop drowning, however as shown in the previous fact, they can breathe underwater. Tests have actually shown they can survive being submerged in water for over two weeks.
Therefore the popular drowning explanation is a myth, and researchers have proposed various other theories. These include –
Earthworms find it easier to travel across the surface when it’s wet (to find food, or a mate). They need to stay moist, so this is their best opportunity on the surface.
Rain drops sound like predators (such as moles, that make vibrations in the soil as they hunt), and subsequently worms come to the surface to escape.
Earthworm and soil experts are starting to settle on the first theory above around enabling them to travel on the surface as the most likely explanation.
Interestingly, birds have recognised and exploit this behaviour by mimicking rain by hitting the ground with their feet to encourage earthworms to rise to the surface to eat them!
- https://factanimal.com/earthworm/