Bacteria are decomposers which break down dead material and recycle it. They also can be producers, making food from sunlight, such as photosynthetic bacteria, or chemicals, such as chemosynthetic bacteria.
The most influential bacteria for life on Earth are found in the soil, sediments and seas. Well known functions of these are to provide nutrients like nitrogen and phosphorus to plants as well as producing growth hormones. By decomposing dead organic matter, they contribute to soil structure and the cycles of nature.
Decomposers play a critical role in the flow of energy through an ecosystem. They break apart dead organisms into simpler inorganic materials, making nutrients available to primary producers.