Bacteria and fungi play an important role in ecosystems because they are decomposers. Decomposers are animals, bacteria, or other plants, (etc..) that consume dead organisms and return fertile soil as a result. The dead organisms they recycle also help them contribute more natural resources like carbon and nitrogen. These resources are released back into the soil, air, and water. Hope this helps! :D