One of the features that made the last two “Avengers” movies distinct from other superhero fare is that the villain, Thanos (Josh Brolin), wasn’t motivated by the usual “take over the world” agenda. As he explained to his adopted daughter Gamora (Zoe Saldana), “It’s a simple calculus. This universe is finite, its resources finite. If life is left unchecked, life will cease to exist. It needs correcting.” When Gamora protested that he couldn’t possibly know that to a certainty, Thanos responded, “I’m the only one who knows that. At least, I’m the only one with the will to act on it.”

If you’re familiar with the work of Thomas Robert Malthus, this logic will sound familiar. In his 1798 book “An Essay on the Principle of Population,” Malthus argued that resource abundance led to population growth rather than a high standard of living and would eventually become unsustainable. Malthus’ ideas remain hotly contested to this day, but they are simple enough — and, perhaps most importantly, easy enough to interpret on behalf of a tyrannical, mass murdering agenda — that it is logical a variation of them to show up in a fictional supervillain’s philosophy.

One of the best things about “Avengers: Endgame,” though, is how it uses that philosophy to look into Thanos’ soul — and how the Avenger who winds up killing Thanos was the living embodiment of the opposite worldview.

When the audience sees Thanos again for the first time in “Avengers: Endgame,” the mad titan has retreated to a garden planet to retire. Notably, one of the first things Thanos did was destroy the Infinity Stones, both so that his work in killing half the universe’s population couldn’t be reversed and so that he wouldn’t succumb to the temptation to use the stones to become a living god. Considering how many comic book fans believe that Thanos is the single most powerful figure in all of comic books, that decision is a big deal. It seemingly establishes that Thanos, no matter how evil his actions may have been, was genuinely motivated by a desire to make the universe a better place rather than by egotism or power lust. And as Captain America/Steve Rogers (Chris Evans) observes to Black Widow/Natasha Romanoff (Scarlett Johansson), a pod of whales has been spotted in the Hudson River, near New York City. The population reduction strategy, though evil, was not without its benefits.

Yet once Thanos begins to see his agenda as an “inevitability” (his word), and is confronted with the possibility that this destiny may be thwarted by the Avengers, a different side of him emerges. Instead of seeing that the moral consequences of his iconic finger snap were too much for the world to bear — that the universe would much rather deal with its resource allocation problems in a humane way than simply kill off half the population — Thanos instead argues that life is stubbornly unwilling to accept the wisdom of his approach, and is therefore unworthy of living…