The Constitution was written in 1787 to establish a new government and address problems with the previous system under the Articles of Confederation. It was influenced by several historical documents and compromises. The framers aimed to create a lasting framework that protected individual freedoms while allowing the government to function and meet the needs of the new nation.