The War of 1812, a war between the United States, Great Britain, and Britain's Indian allies, lasted from 1812 to 1815. The U.S. declared war and historians have long debated the multiple factors behind that decision.
There were several causes for the U.S. declaration of war: First, a series of trade restrictions introduced by Britain to impede American trade with France, a country with which Britain was at war (the U.S. contested these restrictions as illegal under international law); second, the impressment (forced recruitment) of seamen on U.S. vessels into the Royal Navy (the British claimed they were British deserters); third, the British military support for American Indians who were offering armed resistance to the expansion of the American frontier to the Northwest; fourth, a possible desire on the part of the United States to annex Canada. An implicit but powerful motivation for the Americans was the desire to uphold national honor in the face of what they considered to be British insults (such as the Chesapeake affair).
American expansion into the Northwest (Ohio, Indiana, Michigan, Illinois and Wisconsin) was impeded by Indian raids. Some historians maintain that an American goal in the war was annex some or all of Canada, a view that many Canadians still share, while others argue that inducing the fear of such a seizure had merely been a U.S. tactic designed to obtain a bargaining chip. Some members of the British Parliament at the time and dissident American politicians such as John Randolph of Roanoke claimed that land hunger rather than maritime disputes was the main motivation for the American declaration. However, some historians, both Canadian and American, retain the view that desire to annex all or part of Canada was an American goal. Although the British made some concessions before the war on neutral trade, they insisted on the right to reclaim their deserting sailors. The British also had the long-standing goal of creating a large "neutral" Indian state that would cover much of Ohio, Indiana and Michigan. They made the demand as late as 1814 at the peace conference, but lost battles that would have validated their claims.
The war was fought in four theatres: on the oceans, where the warships and privateers of both sides preyed on each other's merchant shipping; along the Atlantic coast of the U.S., which was blockaded with increasing severity by the British, who also mounted large-scale raids in the later stages of the war; on the long frontier, running along the Great Lakes and Saint Lawrence River, which separated the U.S. from Upper and Lower Canada (Ontario and Quebec); and finally along the coast of the Gulf of Mexico. During the course of the war, both the Americans and British launched invasions of each other's territory, all of which were unsuccessful or gained only temporary success. At the end of the war, the British held parts of Maine and some outposts in the sparsely populated West while the Americans held Canadian territory near Detroit, but these occupied territories were restored at the end of the war.
In the United States, battles such as New Orleans and Baltimore (the latter of which inspired the lyrics of the U.S. national anthem, The Star-Spangled Banner) produced a sense of euphoria over a "second war of independence" against Britain. It ushered in an "Era of Good Feelings", in which the partisan animosity that had once verged on treason practically vanished. Canada also emerged from the war with a heightened sense of national feeling and solidarity. Britain, which had regarded the war as a sideshow to the Napoleonic Wars raging in Europe, was less affected by the fighting; its government and people subsequently welcomed an era of peaceful relations with the United States.
The British were engaged in a life-and-death war with Napoleon and could not allow the Americans to help the enemy, regardless of their lawful neutral rights to do so. As Horsman explains, "If possible, England wished to avoid war with America, but not to the extent of allowing her to hinder the British war effort against France. Moreover...a large section of influential British opinion, both in the government and in the country, thought that America presented a threat to British maritime supremacy." 
The British had two goals: All parties were committed to the defeat of France, and this required sailors (hence the need for impressment), and it required all-out commercial war against France (hence the restrictions imposed on American merchant ships). On the question of trade with America the British parties split. As Horsman argues, "Some restrictions on neutral commerce were essential for England in this period. That this restriction took such an extreme form after 1807 stemmed not only from the effort to defeat Napoleon, but also from the undoubted jealousy of America's commercial prosperity that existed in England. America was unfortunate in that for most of the period from 1803 to 1812 political power in England was held by a group that was pledged not only to the defeat of France, but also to a rigid maintenance of Britain's commercial supremacy." That group was weakened by Whigs friendly to the U.S. in mid-1812 and the policies were reversed, but too late for the U.S. had already declared war. By 1815 Britain was no longer controlled by politicians dedicated to commercial supremacy, so that cause had vanished.
The British were hindered by weak diplomats in Washington (such as David Erskine) who misrepresented British policy and by communications that were so slow the Americans did not learn of the reversal of policy until they had declared war.
When Americans proposed a truce based on British ending impressment, Britain refused, because it needed those sailors. Horsman explains, "Impressment, which was the main point of contention between England and America from 1803 to 1807, was made necessary primarily because of England's great shortage of seamen for the war against Napoleon. In a similar manner the restrictions on American commerce imposed by England's Orders in Council, which were the supreme cause of complaint between 1807 and 1812, were one part of a vast commercial struggle being waged between England and France." 
Creating an Indian barrier state between U.S. and Canada
The British also had the long-standing goal of creating an Indian barrier state, a large "neutral" Indian state that would cover most of the Old Northwest and be a barrier between the western parts of the United States and Canada. It would be independent of the United States and under the tutelage of the British, who would use it to block American expansion and to build up their control of the fur trade. They made the demand as late as 1814 at the peace conference, but dropped the demand. Their position had been weakened by the collapse of Tecumseh's Confederacy after the Battle of the Thames, but the British also simply no longer considered the goal worth conflict with the United States. Much of the proposed buffer state remained largely under British and Indian control throughout the war.