Cordyceps is a type of fungus which is parasitic that when a spore infiltrates a host, it starts to take over the host's body. One type of Cordyceps that attacks ants can even control the behaviour of the host.
When an ant is discovered to be infected, the worker ant will carry and dump it as far a possible from the colony. This seems cruel but the infection is vital that it may wipe up the whole colony of ants.
The infected ant will climb upwards on a branch and stick itself there, which is a behaviour affected by the infection. This ensures good environment for the fungus to grow and maximal distribution of the spores from the fruiting body that erupts out of the dead ant.
When the spores spread and infiltrate other ants, the cycle begins again.