There are many poisonous fungi in nature. For example Amanita Phalloides. What reasons could a fungus need poison for? Some species, like venomous snakes, use poison to kill other species as prey. But what about fungi? I can't think of any purpose for poison in fungi. If poison has no real function in fungi shouldn't evolution get rid of it?
The same reason some plants are poisonous: to stop animals from eating them.
The visible part of the fungus is called, rather misleadingly, the fruiting body. It exists to produce and spread spores and thus produce the next fungal generation. Getting eaten, rather obviously, inhibits its ability to do this. Being poisonous discourages animals from eating the fruiting body and thus permits it to complete its life cycle.