The story goes like this: Thomas Carlyle, a Scottish writer and philosopher, called economics "the dismal science" in reference to Thomas Malthus, that lugubrious economist who claimed humanity was trapped in a world where population growth would always strain natural resources and bring widespread misery. Dismal, indeed.
But this origin myth is, well, mythical. Carlyle did coin the phrase "the dismal science." And Malthus was, without question, dismal.
But Carlyle labeled the science "dismal" when writing about slavery in the West Indies. White plantation owners, he said, ought to force black plantation workers to be their servants. Economics, somewhat inconveniently for Carlyle, didn't offer a hearty defense of slavery. Instead, the rules of supply and demand argued for "letting men alone" rather than thrashing them with whips for not being servile. Carlyle bashed political economy as "a dreary, desolate, and indeed quite abject and distressing [science]; what we might call ... the dismal science.”
Today, when we hear the term "the dismal science," it's typically in reference to economics' most depressing outcomes (e.g.: on globalization killing manufacturing jobs: "well, that's why they call it the dismal science," etc). In other words, we've tended to align ourselves with Carlyle to acknowledge that an inescapable element of economics is human misery.
But the right etymology turns that interpretation on its head. In fact, it aligns economics with morality, and against racism, rather than with misery, and against happiness. Carlyle couldn't find a justification for slavery in political economic thought, and he considered this fact to be "dismal." Students of economics should be proud: Their "science" was then (as it can be, today) a force for a more just and, crucially, less dismal world.