Living in groups has costs and benefits. The benefits of social living include the dilution effect in which large groups of prey have a reduced likelihood of being killed by a predator, reduced need for personal vigilance, and increased ability to find food and mates. The costs include an increase in visibility to predators, increased risk of parasite and pathogen transmission, and increased competition for food. In response to social living, many species have evolved the ability to establish territories and dominance hierarchies to manage individual interactions.
There are many types of social interactions. When we envision interactions in terms of donors and recipients, we can devise four types of social interactions: cooperation, selfishness, spitefulness, and altruism. Cooperation and selfishness of donors should be favored by natural selection whereas spitefulness should not. Altruism can be favored when the recipient of an altruistic act is closely related to the donor, as measured by the coefficient of relatedness.
Eusocial species take social interactions to the extreme. Eusocial animals consist of many individuals living together with dominant individuals reproducing and subordinate individuals forgoing reproduction. Eusocial species are common among the haplodiploid species of bees, ants, and wasps, but also exist in diploid species of termites and at least two species of mammals. A high coefficient of relatedness favors the evolution of eusocial behavior, but it is not required. Equally important may be the presence of a low cost of lost fitness in species that have a low probability of leaving the group and reproducing on their own.