Where a civil law is so perverse as to cross all the interests of society, it loses all its authority, and men judge by the ideas of natural justice, which are conformable to those interests.
 David Hume, An Enquiry Concerning the Principles of Morals (1751). copy citation

Context

“Not to mention, that our obligation itself to obey the magistrate and his laws is founded on nothing but the interests of society. If the ideas of justice, sometimes, do not follow the dispositions of civil law; we shall find, that these cases, instead of objections, are confirmations of the theory delivered above. Where a civil law is so perverse as to cross all the interests of society, it loses all its authority, and men judge by the ideas of natural justice, which are conformable to those interests. Sometimes also civil laws, for useful purposes, require a ceremony or form to any deed; and where that is wanting, their decrees run contrary to the usual tenour of justice; but one who takes advantage of such chicanes, is not commonly regarded as an honest man.” source