The US Constitution was written in 1787 after the Second Continental Congress called for a convention in Philadelphia to modify the Articles of Confederation, the document that served as the foundation for the United States' first national government. On May 25, 1787, fifty-five delegates from twelve of the thirteen states (Rhode Island boycotted the convention) converged on Philadelphia intent on solving problems that arose from weaknesses in the Articles of Confederation. The written authorization was "to devise such further provisions as shall appear to [the delegates] necessary to render the constitution of the Federal Government adequate to the exigencies of the Union."
Some of the issues they needed to address was the lack of Executive and Judicial Branches (no federal court system), a means of providing fair representation for states of unequal population, a way of mediating disputes between the states, provision for taxing power or other means of raising revenue, and related issues.
The first order of business was to elect George Washington to serve as President of the Convention, and to establish rules of procedure.
During the course of debate, it soon became clear that the Articles of Confederation, written only a decade earlier in 1777, were unsalvageable as a framework for the envisioned Republic, so the delegates decided to write a new Constitution.
Some delegates were outraged by the idea and left the convention early. Those who remained gradually worked out a system of plans and compromises that they believed would create a strong central government without depriving the states of all sovereign authority.
On September 17, 1787, thirty-nine of the fifty-five delegates signed the Constitution and agreed to promote its ratification to their state legislatures.
As required under Article VII, the ninth state ratified the Constitution on June 21, 1788, and the new federal government became operational on March 4, 1789.