Summary: This is a complex subject. Recent studies have shifted the balance of importance towards behavior. The contribution of genes to the variation in longevity is now believed to be less than 10%.
Studies look at longevity variations across relatives. However, in addition to common genes, there are likely to be common environmental, “sociocultural” factors. Attributing longevity variations between these factors is a challenging data and statistical activity. The study Estimates of the Heritability of Human Longevity Are Substantially Inflated due to Assortative Mating analyzed 54.43 million family trees from 406 million people’s birth and death records. The data came from Ancestry.com, spanning the nineteenth century and the first half of the twentieth century.
The study concluded that: the true heritability of human longevity for birth cohorts across the 1800s and early 1900s was well below 10%, and that it has been generally overestimated due to the effect of assortative mating.
Assortative mating is when people with similar genotypes mate with each other with greater frequency than expected by a random pattern. For example, deaf people tend to marry each other.
For a little more detail, and references, please see here.