Some types live near the soil surface. They love to eat rotting food waste and turn it into nutrient-rich soil. We call these compost worms.
You can buy compost worms in stores; they are easy to rear in captivity. Other earthworms live deeper within the soil. They eat soil and plant residues and are called soil-dwelling worms. Soil-dwelling worms do important work improving soil structure.