Some cases of costly helping are explained by genetic relatedness.
Considering larger contexts can inform analysis of other cases of costly helping, as well. For example, honeybees, and many wasps and ants, along with the burrowing naked mole rats from eastern Africa include individuals that do not reproduce. Rather, they contribute to the reproduction of a single individual in a social setting. The failure to perpetuate one's own lineage seems to contradict the principle of natural selection. Yet it is the evolutionary context that also proves significant here. In a broader scope, lineages include collateral relatives and their descendents, who share on average certain percentages of one's heritable traits. Under appropriate circumstances, contributions to their survival and reproduction may well outweigh the individual's. In such cases, costly behavior towards relatives may develop. Natural selection is indirect. The helping traits are preserved and proliferate through relatives, not direct offspring: kin selection. For long-term evolution, a proper measure is thus not individual fitness, but inclusive fitness, the total representation of one's traits in future generations (Hamilton 1964).
The outcome of kin selection is well illustrated by honeybees (Apis melifera). Each hive is typically dominated by one large "queen" bee that reproduces. The other bees are her offspring. While also female, they are sterile and work in the hive supporting their sisters, rather than mating on their own. This behavior reflects the bees' distinctive genetics. The queen is haploid, the female workers (and males) diploid. Paradoxically from a human perspective, workers are more closely related to their sisters (75%) than to their own children (50%)! When a honeybee dies defending the hive, she increases the chances that the queen and her many sisters — the lineage expressing her traits — all continue. Through indirect kin selection, the helping behavior, while costly, increases her inclusive fitness. Many other insects exhibit similar genetics and, not surprisingly, also similar social organization.