Philippa Foot is most known for her invention of the Trolley Problem thought experiment in the 1960s. A lesser known variation of hers is as follows:
Suppose that a judge is faced with rioters demanding that a culprit be found for a certain crime. The rioters are threatening to take bloody revenge on a particular section of the community. The real culprit being unknown, the judge sees himself as able to prevent the bloodshed from the riots only by framing some innocent person and having them executed.
These are the only two options: execute an innocent person for a crime they did not commit, or let people riot in the streets knowing that people will die. If you were the judge, what would you do?
The answer is dependent on context I think.
I’m a universe where the whole future of the world is laid out before you and you can choose 1 death or many deaths, then sure, pick the greater good.
The weakness of simplistic “greater good” automatic arguments is that in a real universe it opens you up to manipulation.
In the end, there’s no avoiding thinking through the incentives from all perspectives. And that indeed suggests not giving in to the rioters, to protect the integrity of the entire legal system and reduce the risk that every trial becomes a show trial dictated by whoever has the biggest mob.