There are more living beings in a handful of soil than there are humans on earth: worms, beetles, spiders, mites, larvae, bacteria, algae, fungi, not to speak of many others. They decompose dead animal and plant material, for example fallen leaves.
The material that small creatures like beetles and spiders cannot break down is taken over by even smaller organisms like bacteria and fungi. As a result of this step-by-step decomposition soil organisms form what is known as humus and thus provide the nutrients for plant growth. At the same time they loosen and aerate the soil.