Social contract theory is the dominant Western framework for justifying political authority. The basic move: imagine humans before government — Hobbes' "state of nature," Locke's pre-political community, Rousseau's natural innocence. Ask what arrangement those people, reasoning carefully about their interests, would have agreed to. Whatever they would have agreed to, you (today) have implicitly consented to by participating in the arrangement.
The three founders disagree sharply. Hobbes thought the state of nature was so brutal — "solitary, poor, nasty, brutish, and short" — that rational agents would consent to almost any sovereign capable of keeping order. Locke had a friendlier view: even in the state of nature, people have rights to life, liberty, and property; legitimate government protects these, and loses legitimacy when it violates them. Rousseau argued that civilization itself had corrupted us, and only a radical reconstruction (the general will) could restore freedom.
John Rawls revived the tradition in the twentieth century with his "veil of ignorance" — imagine choosing the basic structure of society without knowing what role you'd play in it. Rawls argued you'd pick a society where the worst-off were as well-off as possible. Robert Nozick fired back that any pattern enforced by the state inevitably violates individual rights to free transaction. The argument continues because the question is unavoidable: every state demands obedience; every state owes its citizens a story for why.