in an ecosystem, fungi play the role of decomposers -- they break down dead organic matter and return vital nutrients to the soil. Without fungi, nutrients would not cycle through an ecosystem, causing the breakdown of the entire food chain.
hope this helps :)