Why are some fungi poisonous?
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.