There is tons of research on this. Higher IQ at young ages, independent of social class, strongly predicts health outcomes. Since it also predicts income, and since a big part of IQ can be predicted before birth, IQ seems to be the real driver here.
From here: https://en.wikipedia.org/wiki/Cognitive_epidemiology
A strong inverse correlation between early life intelligence and mortality has been shown across different populations, in different countries, and in different epochs."[3][4][5]
A study of one million Swedish men found showed "a strong link between cognitive ability and the risk of death."[6][7][8][9]
A similar study of 4,289 former US soldiers showed a similar relationship between IQ and mortality.[7][8][10]
The strong correlation between intelligence and mortality has raised questions as to how better public education could delay mortality.[11]
There is a known inverse correlation between socioeconomic position and health. A 2006 study found that controlling for IQ caused a marked reduction in this association.[12]
Research in Scotland has shown that a 15-point lower IQ meant people had a fifth less chance of seeing their 76th birthday, while those with a 30-point disadvantage were 37% less likely than those with a higher IQ to live that long.[13]