As saprophites, also called saprobes, they digest dead organic matterial and help clean up the enviroment. They get rid of dropped leafs, old logs, whatever is available.
As symbiots, mutualistic growth with another organism. Lichens are one example, algi and fungi together. The fungi feed the algi nutrients for growth and protect them from drying out. The agli provide sugars for the fungi to spread. It’s more involved but a that’s a short version. Another, mycorrhizal symbiosis where the fungi grow into the roots of plants, supplying minerals and products of their breakdown of organic materials and water, plants supply sugars. Again, short and nasty. There’s more to it. There are more ‘relationships’ as well.
As parasites, feeding on living tussues. Ring worm, atheletes foot, farmers lung, corn smut, dutch elm disease…. The list goes on.