http://www.earthwormsoc.org.uk/earthworm-information/earthworm-information-page-3
Soil structure
Earthworms have been called ‘ecosystem engineers’.
Much like human engineers, earthworms change the structure of their environments. Different types of earthworms can make both horizontal and vertical burrows, some of which can be very deep in soils.
These burrows create pores through which oxygen and water can enter and carbon dioxide can leave the soil.Earthworm casts (their faeces) are also very important in soils and are responsible for some of the fine crumb structure of soils.
Decomposition and soil organic matter
Earthworms play an important role in breaking down dead organic matter in a process known as decomposition. This is what the earthworms living in your compost bin are doing and earthworms living in soils also decompose organic matter. Decomposition releases nutrients locked up in dead plants and animals and makes them available for use by living plants. Earthworms do this by eating organic matter and breaking it down into smaller pieces allowing bacteria and fungi to feed on it and release the nutrients.
Earthworms are also responsible for mixing soil layers and incorporating organic matter into the soil. Charles Darwin referred to earthworms as ‘nature’s ploughs’ because of this mixing of soil and organic matter. This mixing improves the fertility of the soil by allowing the organic matter to be dispersed through the soil and the nutrients held in it to become available to bacteria, fungi and plants.
Bacteria and fungi
Earthworms have a positive effect on bacteria and fungi in soils. Where earthworms are present there are more bacteria and fungi and they are more active. This is important as bacteria and fungi are key in releasing nutrients from organic matter and making them available to plants. They are also an important source of food in their own right for many other animals that live in soils.