Most people assume that earthworms come to the surface during heavy rains to avoid drowning in their tunnels. In fact, worms can live totally submerged in water, so drowning isn’t the problem. But the rainwater that filters down through the ground contains very little oxygen, so the real reason earthworms come to the surface is to breathe.
Once above ground, earthworms are very sensitive to light, and even a brief exposure to the sun’s rays can paralyze them. Unable to crawl back into their burrows, they eventually dry out and die on the sidewalk.