In John Locke's 'Two Treatise of Government', he wrote the state of nature is the basis of how governments emerged. In his state of nature, there is a law that governs us all. It is the law of reason.
It is through this law that humans started to understand the need of an authority to govern them all and to protect their interests.
Subsequently, this authority became into a legitimate government in time.
John Locke firmly believed that every man can lively freely and equally based on reason and not under the authority of any superior king or man.