On guard
The mushrooms of parasitic fungi are very attractive to insects. Their smell is way better than things insects would normally smell, which makes the insects want to eat them. On the other hand, these insects also know that these fungi or some spores are dangerous. Especially for insects living in colonies or in nests like ants or bees or termites, that is why most of them have guards in front of their nests. Each ant, each bee gets checked if they have spores of the wrong fungi on their body. And if they do, they get killed and brought away. Once these parasitic fungi are in their nest, their nest is destroyed. Future
Insect Mindgames
Somehow, some fungi are able to control the brain of insects and control them. One of the main goals of fungi is to spread their spores as far and wide as possible. One of the ways they do this is to use an insect as a vehicle and kill it when it is time. For example, the fungi make the insect go up in a tree and sit on top of a leaf. Normally this is way too dangerous for an insect because it becomes easy prey, but the fungi controls it and makes the insect go there on purpose. Once the insect has a good spot, the fungi kills the insect and grows a mushroom. This results in a perfectly presented snack for a bird, which means the bird becomes the new vehicle for the spores. The fungi cannot control the bird's brain, but that is not necessary as the bird will poop and drop the spores, which serves the goal of the fungi. In this way, the spores land in a new spot, which may attract new insects and so the cycle goes on. There is a lot of videos on this on the internet, also with fungi in suicidal snails.
Fungi Farming
Next to the parasitic way, there is also the symbiotic relationship between insects and fungi. There are a lot of ants and termites that cultivate fungi for eating. It even goes as far as that they co-involve. Some ant colonies are not able to get enough food from outside, so they are dependent on the fungi. But also this fungi is not able to live without the shelter and conditions of the ant colony. When a new colony is started somewhere else by a new ant queen, she will take a piece of the fungi with her. Without the fungi, the ants will not survive, and vice-versa for the fungi.