They essentially do what humans do. They eat the food, which in this case is decaying materials (detritus), break down the material chemically and mechanically, absorb the nutrients they need, then excrete the 'waste', which contains other nutrients. Soil is basically clay, sand, silt and decomposer's cr*p.