A mechanism that produces acts of assistance has an evolutionary advantage over alternative mechanisms, if it reliably causes Individual i to help Relative j whenever Ci < rijBj.
In this equation,
Ci = cost to i of rendering an act of assistance, measured in terms of foregone reproduction,
Bj = benefit to j of receiving that act of assistance, measured in terms of enhanced reproduction,
rij = the probability that a randomly sampled gene will be at the same locus in the relative due to joint inheritance from the same ancestor
Established by W. D. Hamilton in his book "The genetic evolution of social behavior" (1964).
What this means is that genes which cause a behaviour in an individual to help its relatives are selected for, if the cost of this is smaller than the benefit to the other, multiplied by the degree of relationship, rij (this is 0.5 on average for siblings, 1.0 for identical twins, and so on).
Keep in mind that this rule is mathematically proven, but the extent to which genes cause behaviour in adult humans is still heavily debated. See Evolutionary Psychology and Nature vs. Nurture