In the early Platonic dialogue, Crito, Socrates makes a compelling argument as to why he must stay in prison and accept the death penalty, rather than escape and go into exile in another Greek city. He personifies the Laws of Athens, and, speaking in their voice, explains that he has acquired an overwhelming obligation to obey the Laws because they have made his entire way of life, and even the fact of his very existence, possible.

They made it possible for his mother and father to marry, and therefore to have legitimate children, including himself. Having been born, the city of Athens, through its laws, then required that his father care for and educate him. Socrates’ life and the way in which that life has flourished in Athens are each dependent upon the Laws. Importantly, however, this relationship between citizens and the Laws of the city are not coerced. Citizens, once they have grown up, and have seen how the city conducts itself, can choose whether to leave, taking their property with them, or stay. Staying implies an agreement to abide by the Laws and accept the punishments that they mete out. And, having made an agreement that is itself just, Socrates asserts that he must keep to this agreement that he has made and obey the Laws, in this case, by staying and accepting the death penalty. Importantly, the contract described by Socrates is an implicit one: it is implied by his choice to stay in Athens, even though he is free to leave.

https://www.iep.utm.edu/soc-cont/#H2