The philosopher John Locke had fled England for the Netherlands in 1683 under strong suspicion of involvement in the Rye House Plot against King James II (though there is little evidence to suggest that he was directly involved in the scheme).
In the Netherlands, Locke had had time to return to his writing, spending a great deal of time reworking what would become An Essay Concerning Human Understanding and composing what would become the Letter on Toleration.
Having returned to England in 1689 in the party escorting the princess of Orange, he anonymously publishes a work of political philosophy, The Two Treatises of Government (or Two Treatises of Government: In the Former, The False Principles and Foundation of Sir Robert Filmer, And His Followers, are Detected and Overthrown. The Latter is an Essay concerning The True Original, Extent, and End of Civil-Government).
The First Treatise attacks patriarchalism in the form of sentence-by-sentence refutation of Robert Filmer's Patriarcha and the Second Treatise outlines a theory of civil society based on natural rights and contract theory.
Locke claims in the "Preface" to the Two Treatises that its purpose is to justify William III's ascension to the throne, though the bulk of the writing may have been completed between 1679-1680 (and subsequently revised until Locke was driven into exile in 1683).