To Locke, civil government was/is the result of the people entering into a "social contract." Locke believes that all people have the right to life, liberty, and property but that without government, they are unable to protect those rights unless they are strong enough to do so.
Because this "state of nature" would not be very pleasant, people choose to enter into a social contract. Essentially, they form a civil government and make a deal with that government. The government will protect their life, liberty, and property and they, the people, will obey the government.
To Locke, the people may withdraw their consent if the government is not doing a good job of protecting their rights.
Locke's ideas are repeated quite faithfully in the US Declaration of Independence.
According to John Locke, a civil government is one gives authority to the people over their government. He brought this out through his Two Treatises and especially in the second section. He started by arguments against Filmer’s assertion of the patriarchal system of authority (first treatise), where the leader is divinely ordained, the power over the people is absolute and the leadership is hereditary. By arguing against these aspects as stated by Filmer, Locke described a civil government where people agreed on the leader through consent as required by natural justice. Locke asserted that having a leadership with absolute power creates an environment that can easily turn the people into slaves. He stated that people exist in a state of freedom and are bound to the limits established by the laws of nature. This state gives them the power to exercise their own decisions and makes them equal with no subordination among them. However, in order to protect their freedoms the people come together to form a civil society by establishing a social contract with the government which in turn manages their affairs. Thus a civil government’s authority is established through the consent of the people and is its leadership.
The concept of "social contract", where if the people follows the government, the government will guarantee their basic rights.