What is the purpose of a government?

The fundamental purpose of government is the maintenance of basic security and public order.

Government provides a system in which individuals give a portion of their freedom in order to pursue needs and wants without the fears that are inherent in a state of anarchy.

In an anarchic system, individuals must protect and provide completely for themselves, and those with greater power are able to offend those with lesser power without consequence. In a system of government, the freedom to acquire and offend at will is subjugated to the will of the governed; and, in return, the governed are better able to produce without fear of loss.

Therefore, at its most basic level, the purpose of government is to protect the people from threats, both within and without.

Note on edits: Individuals can pursue life, liberty, happiness and property (blending Locke and Jefferson) without government. Government cannot not grant happiness.