The Question:

What is the scientific reason worms come up onto the pavement or
cement when it rains?

The Answer:

The misconception is that worms surface during
rain storms because they would drown in their borrows if they did not.
However, the truth is almost the exact opposite.

Worms don't have respiratory systems like
humans. They take in oxygen through their skin which is covered in
tiny mucus-secreting cells. For this reason, a worm's skin needs to
stay moist for it to survive. Dry skin means death to a worm.

When it rains, worms leave the ground because the wet ground is
much easier for them to navigate, plus they don't have to worry about
drying out in the hot sun. Most often when they come to the surface
they are doing so because it's easier to find mates on the flat open
ground as compared to underground in their burrows.

Gardener John Mertus said it best in his article on earthworms: “To an
earthworm, the wet ground is a wild singles bar.”