Earthworms actually breathe through their skin, which means that their mechanism for gas exchange involves their entire body. This means that oxygen comes in through the skin and that carbon dioxide ultimately exits the same way. Inhalation draws air through the skin, and the oxygen dissolves in dampness on the skin of the worm, entering the capillaries directly.
Once the oxygen is making its way around the worm's bloodstream along with the hemoglobin, the carbon dioxide begins replacing the oxygen inside the transit. When the blood makes its way back to the skin, the carbon dioxide leaches out through the skin, and the gas exchange cycle is complete.
The mechanics of breathing is not the only unique feature that earthworms possess. They use their pharynx to bring soil or other food into their mouths, and the esophageal glands add some chalk to get rid of acid content in the soil. The crop gives the food a temporary storage place, but then it enters the gizzard, which has a lining designed to grind the food down into more manageable bits. The intestine absorbs the food, but anything that is not digested simply leaves the worm's boy through the anus, entering the soil as "worm casts."