Every time disaster strikes, the pattern repeats itself. Whether it’s a hurricane, wildfires, or a pandemic, every disaster brings with it a fresh round of complaints that merchants are engaged in “price gouging.”

And, predictably, each time such complaints appear, so does a wave of opinion pieces by economists defending price increases as an efficient way to ration excess demand and incentivize increased supply.

The economists’ response is cogent as far as it goes, but it leaves most people unmoved. However efficient, most people still think that price gouging is deeply immoral.

As it turns out, the question of what makes a price fair has been debated by moral philosophers ever since the time of the ancient Greeks. And while those debates provide some support for the modern condemnation of price gouging, the ethical issues involved turn out to be a good deal more complicated than most people appreciate.

One of the earliest theories of the just price was developed in Ancient Greece by Aristotle. Aristotle thought that a just exchange involves a kind of equality. To trade fairly with another person is to give up something of equal value to what you get. The value of a thing, in turn, is the function of the need it satisfies—a house is of higher value than a book, because the house satisfies a greater need. And the need, in turn, is roughly measured by the amount of money one is willing to pay for it.

Around 1,500 years later, St. Thomas Aquinas took Aristotle’s view one step further. If value is a function of need, and money is the mechanism for measuring and comparing need, then the just price is equivalent to the market price—the price that emerges out of the process of various people’s needs competing through the marketplace. And just as the market price will vary from place to place and time to time according to considerations of supply and demand, so, too, will the just price.

The conclusion that the just price is the market price—a conclusion that would stand as the dominant understanding of the just price throughout the history of the idea—does not mean that anything goes. Aquinas, for instance, thought that if you had a good that someone else desperately needed, and that you could easily part with, it would be wrong to raise the price in order to take advantage of that desperation.

John Locke, writing about 400 years later, took a similar position. But, interestingly, while Locke thought it would be wrong to take advantage of the desperation of particular buyers, he nevertheless held that a just price could and should reflect the desperation of the market as a whole. If there’s a famine in Dunkirk, he wrote, but no famine in Ostend, then it’s morally permissible to sell grain for a higher price in Dunkirk than in Ostend.

Locke’s position might sound callous, but it’s grounded in a humanitarian concern to ensure that people get what they need to survive in difficult times. Forcing sellers to sell at the same price in a famine as they do in normal conditions could mean that buyers in the famine-struck city wind up with nothing at all, because goods sold at less than the market price would be snatched off the shelves and hoarded, or resold on the secondary market.

Preventing prices from rising doesn’t do anything to fix the underlying scarcity that caused those prices to rise in the first place.

What does all of this say about contemporary debates over price gouging? On the one hand, of course it is wrong to use your neighbor’s suffering as an opportunity for your own gain. On the other hand, a system of market prices that accurately reflects conditions of supply and demand plays a vital role in promoting human well-being for precisely the reasons that contemporary economic critics of anti-gouging laws point out.

In the end, we don’t necessarily have to choose sides. The economists are probably right that laws prohibiting price gouging are misguided and likely to produce harmful unintended consequences. But the critics of price gouging are partly right, too.

Just because you have a right to charge a high price doesn’t mean that it’s always the right thing to do. Determining when it is, and when it isn’t, is a difficult and context-dependent decision. In other words, it’s precisely not the kind of question best settled by the blunt instrument of legal regulation.