Being at the bottom of the social ladder is generally a predictor of bad health: research shows that poor people die sooner and have more disease than rich people, even when you account for factors like lack of access to health care.

But the data on social hierarchy and health — including studies in primates other than humans — contains a paradox for males: high status is linked with high levels of testosterone, and high testosterone can in turn lower immunity and increase disease risk. So, why is high rank consistently associated with good health? A new study in baboons sheds new light on the connections.

Scientists examined data collected over 27 years in wild baboons living in the Amboseli region of Kenya. The researchers looked specifically at the relationship between illness and injury and rank — that is, whether higher- or lower-ranking males fell ill or were hurt more frequently; scientists also measured how fast the males recovered. (Females were not studied due to complexities related to their reproductive cycles and childbirth.)

The researchers saw significant differences, all favoring the higher-ranked animals. In fact, at any particular time, the odds of recovery from sickness or injury for a high-status animal were three times greater than for a male at the bottom. The alpha males at the very top healed faster than all other males. And this outcome occurred even when the high-ranking males had high levels of stress hormones called glucocorticoids, as well as high levels of testosterone, both of which can suppress immunity.

Based on their stress and hormone levels, one would expect the males at the top to get sicker and recover from wounds more slowly than their low-on-the-totem-pole peers. In part, the findings can be explained by age: top-ranked males tend to be younger and healthier than lower-ranking animals. Still, age didn’t account for the differences completely. Indeed, high status was a better predictor of healing than age was.

The researchers write:

[A]lpha and low-ranking males seem to experience elevated glucocorticoids as a result of different stressors and over different periods of time; such differences may alter the immunosuppressive effects of stress. Specifically, high glucocorticoids in alpha males probably are caused primarily by energetic stress, whereas high glucocorticoids in low-ranking males probably are caused largely by social stressors, [such as] high rates of received aggression, a lack of a sense of control, and few coping mechanisms.

In other words, the short-term stress experienced by alpha males tends to be “good” stress, the kind that comes from exercise or sex. It doesn’t last long, it doesn’t include feelings of loss of control and it doesn’t involve a persistent threat to important social relationships. When you consistently win battles for dominance, you don’t worry much about how the losers will treat you.

In contrast, lower-ranked males experience ongoing, uncontrollable stress, which does affect their relationships, particularly the amount of bullying they face from higher-ranked males. Among baboons, “displacement” aggression is common, wherein the top guy kicks the guy below him when he’s pissed off and that guy kicks a lower-ranking dude, all the way down the chain. This leads to chronically elevated stress hormones in low-ranking members of the pack, which can be harmful.

The top animals also tend to get more social support. In baboons, this involves being groomed by others, which not only removes parasites, but more importantly, also calms the stress system and lowers the animal’s levels of glucocorticoids.

In the short term, then, elevated levels of testosterone and glucocorticoids seem to improve immunity; if they remain consistently high, however, they lower immunity and harm health. Social contact seems to be an important way to “turn down” the stress system.

The researchers note that the study cannot determine whether an animal’s high or low rank is caused by its health status in the first place, or vice versa — and these explanations aren’t mutually exclusive. Strong, resilient animals may rise through the ranks, and then their alpha position may reinforce their good health. Similarly, poor health may drive rank downward by impairing an animal’s performance. The authors write: “It is likely that both forces interact to shape differences in health and immune function.”

In humans, decades worth of data suggest it is higher social status itself that improves health, and the chronic stress of low social status that harms it, particularly when this stress starts early in life.

As pioneering stress researcher Robert Sapolsky — who has studied baboons in Amboseli himself — told me: “When humans invented inequality and socioeconomic status, they came up with a dominance hierarchy that subordinates like nothing the primate world has ever seen before.”

There is, however, a remedy for status stress that works even in the face of social inequality. While humans don’t typically groom each other like baboons, research finds that high levels of social support — especially physical contact like hugs and massage — can mitigate the effects of stress for humans, too. We can’t all be alphas or betas, but we can all love and be loved.

The study was published in the Proceedings of the National Academy of Sciences.

Maia Szalavitz is a health writer for TIME.com. Find her on Twitter at @maiasz. You can also continue the discussion on TIME Healthland‘s Facebook page and on Twitter at @TIMEHealthland.