Warning: This post contains spoilers.

After nearly a decade, Game of Thrones is complete. A global phenomenon averaging more than 44 million views per episode, its soaring popularity met with extreme disappointment at the show’s ending. Critics and fans accused the show’s writers of betraying beloved characters like Daenarys Targaryen, and more than a million fans even signed a petition to demand a remake of the final season.

What happened? We think moral psychology holds clues to why the show was both so beloved by its fans and yet so reviled in its finish. Though Game of Thrones is set in an incredible fantasy world filled with dragons, magic and ice-zombies, the moral challenges that its characters face are very real and follow a deep logic. But this logic was disrupted in the final episodes.

The inhabitants of Westeros and Essos repeatedly face versions of a classic moral dilemma: When is it morally permissible to cause harm in order to prevent further suffering? Philosophers have debated moral dilemmas like this for over a thousand years. “Utilitarian” theories say that all that matters for morality is maximizing good consequences for everyone overall, while “deontological” theories say that some actions are just wrong, even if they have good consequences.

The tension between deontological and utilitarian ethics can be seen in the origin story of Jaime Lannister’s sobriquet “Kingslayer”: When the “Mad King” Aerys Targaryen orders for the entire city to be burned, massacring the many thousands of citizens that live there, Jaime violates his sacred oath to protect and serve his lord and instead slits the king’s throat. Utilitarian theories would praise Jaime’s decision to kill the Mad King, because it saves many thousands of lives, while deontological theories would prohibit killing one to save many others.

When psychologists study utilitarianism, they focus almost exclusively on sacrificial dilemmas like the one Jaime faced. This is what we call “instrumental harm”—asking people whether, for example, they think it’s morally acceptable to harvest a healthy person’s organs to save the life of a dying patient. Game of Thrones is replete with such examples: for instance, when Olenna Tyrell organizes the murder of Joffrey Baratheon; when Daenerys invades Slaver’s Bay to free the slaves, and when Jon Snow, in the series finale, murders Daenarys to prevent her from killing more innocent people. As Tyrion presciently remarks of Daenarys in the final episode, “She believes her destiny is to build a better world.... Wouldn't you kill who stood between you and paradise?” This could well be a utilitarian motto: to create paradise for all on earth, some might need to suffer.

Decades of research (reviewed in Joshua Greene’s bestseller Moral Tribes) suggests that making such utilitarian sacrifices for the greater good typically requires individuals to deliberately overcome an emotional aversion to harming others. Such decisions, correspondingly, often take longer to make and are associated with cognitive and neural processes associated more with deliberation than emotion.

But because this focus has always been on harming others instrumentally, it is therefore not so surprising that research has linked utilitarian decisions to psychopathy. At least some conclude, therefore, that utilitarians are not nice people, and in our own work we find that people tend to distrust those who make utilitarian decisions in moral dilemmas.

It turns out, however there is another key psychological dimension of utilitarianism that is often ignored. This is what we call impartial beneficence: the idea that we should help others as much as we can from a completely impartial perspective, giving no special weight to ourselves or to our family or friends. We should, in the words of one famous utilitarian thinker, make moral decisions from the point of view of the universe. This is the more “positive” aspect of utilitarianism, associated with contemporary efforts to help people in the developing world, fight against animal suffering, and so on.

In the Game of Thrones universe, impartial beneficence is fully on display at the Battle of Winterfell, where lords and ladies of the rival noble houses set down their personal rivalries and fight the army of the dead together. Faced with almost insurmountable odds, they prepare to sacrifice themselves for the benefit of the entire continent. Cersei Lannister, by contrast, scores low on impartial beneficence: while she cares deeply about herself and her children, she has no concern for anyone else. In blowing up the Sept of Baelor with wildfire, she destroys thousands of lives to protect herself and her son. So, too, does Littlefinger, who “would see this country burn if he could be king of the ashes.”

Instrumental harm and impartial beneficence are both theoretically and psychologically distinct: people who score high on one do not tend to score high on another, and they have different social consequences. And while of course ordinary people rarely act completely in accordance with ethical theories created by philosophers, it is certainly possible to identify exemplars in Game of Thrones who personify the dimensions.

Varys, master of whisperers, is probably the best example of a “true” utilitarian in the show, joining both high impartial beneficence and instrumental harm. All the way back in season one, Varys endorsed the assassination of a young Daenerys, recognizing that “we who presume to rule must sometimes do vile things for the good of the realm.” But Varys is far from a psychopath, because his strong endorsement of instrumental harm is matched by an equally strong commitment to impartial beneficence.

For Varys, the political intrigue only matters because of the multitudes who suffer under a bad leader. His loyalties lie “not with any king or queen, but with the people.” With no loyalties to any particular house or leader, Varys is truly impartial. And when he betrays Daenerys, seeing her for the tyrant she is but knowing his betrayal will lead to his death, he performs the ultimate self-sacrifice.

This brings us to the “Mad Queen” herself. Much hay has been made over Daenerys’ heel turn in the final episodes of the show, with critics and fans alike decrying her character arc. The Telegraph suggested that her shift in the penultimate episode led to the series being “ruined beyond repair,” and Wired said it was the “worst episode ever.” As the Atlantic said, her turn was “extremely obvious in some ways ... and absolutely illogical in others.”

One explanation for this that Daenerys had been presented to us throughout the show as high on both instrumental harm and impartial beneficence, like Varys. Although she repeatedly proved willing to burn cities to the ground, this was ostensibly in service of creating a world where all lives counted equally—to “break the wheel” of ruling houses crushing common people under its weight.

But her actions in the end broke the logic of impartial beneficence, and even, arguably, the logic of instrumental harm. Burning King’s Landing after the Lannister army surrendered served no instrumental purpose apart from inspiring fear, and the prioritization of that fear over innocent lives suggested Daenerys ultimately cared more about her own power than the welfare of others. And without impartial beneficence, utilitarian leaders are just psychopathic.

Ultimately, then, it may be impartial beneficence that is crucial for successful leadership, whether in Westeros or in our own world. In this sense, the unlikely “winner” Bran is fitting: devoid of human wants, and with an ability to see the past, present, and future, he can truly make decisions from the point of view of the universe.