I was taught the example below as an undergrad and I think it may originally be due to Pigou (or perhaps, as you will see, it was made up by British Rail):

Suppose travelers can either drive to get from A to B or take the train.  The road is free and tolls are technologically infeasible.  Using the train requires buying a ticket.  In fact, the railways are nationalized and, in a narrow definition of the first-best, they should price at marginal cost (this is a pre-privatization example!). This means too many people will drive, imposing costs on each other and speeding up depreciation of the road.  One solution: subsidize train tickets and price them below cost.  One departure from optimality – the inability to charge a toll on the road – leads to another – pricing below cost on the train.  The theory of the second-best.

Now let’s turn to torture in medieval Continental Europe.  The law was administered by professional judges and sentences often involved maiming or death.  As the punishment was so severe, the proof had to be overwhelming: Conviction required the testimony of two eyewitnesses to the crime.  No circumstantial evidence was allowed.  Let us take the two eyewitness rule as a constraint, like the no toll rule for the road.

What can the judge do if there are less than two eyewitnesses but there is circumstantial evidence that the prisoner is guilty?  The judge is then allowed to use torture to extract a confession.  To prevent false confessions, the prisoner has to give up details only someone who is guilty might know.  Dealing with one constraint, the two eyewitness rule, leads to the use of torture, presumably not the best way to introduce circumstantial evidence into judicial proceedings.

There was much room for abuse (leading the prisoner during torture so they know details of the crime etc).  Torture was eventually outlawed in judicial proceedings.  There are many theories for why.  The most prosaic suggests that with incarceration replacing maiming as a tool for punishment, standards for proof could be relaxed.  In England, torture was not used as trial was by jury.  A jury at that time (or even now?) could take any old fact, circumstantial or not, into account in their deliberations.   No need to torture a prisoner when you can convict him on whim anyway!

My source: The Legal History of Torture, John H. Langbein in Torture: A Collection.