As the preceding answer suggests, the phrase "war to end all wars" was first used by H.G. Wells. Wells, like many idealists of his time, hoped that the sheer destructiveness of the First World War, unprecedented in its time, would persuade mankind to abandon war as a means of solving political disputes.
Many agreed, most notably including President Woodrow Wilson, who argued that the war could become a catalyst for promoting democracy. He famously called the conflict a war to make the world "safe" for democratic institutions. In order to make this happen, Wilson thought the war needed to end in a "peace without victory" in which the powers involved in the conflict would agree on a negotiated peace. Wilson, like many others, thought that the specter of communist revolution, as seen in Russia, would persuade the powers to come together. Wilson went so far as to issue "Fourteen Points" upon which any lasting peace had to be based. In particular, he advocated for an international organization meant to keep the peace.
In the end, the hope harbored by people like Wells, Wilson, and many other politicians and intellectuals would not be realized. Despite the destruction wrought by the First World War, which destroyed generations in the belligerent nations, perhaps the greatest tragedy of the war was that it paved the way for an even more destructive conflict less than three decades later.
First, please note that people do not call World War I “the war to end all wars” anymore unless they are being ironic. The idea that WWI would end all war was a hope that was cherished by some people at the time. However, it very quickly became clear that this was a misguided hope.
The phrase “war to end all wars” was first used by the British author H. G. Wells. He, and others, felt that this war would put an end, once and for all, to the sort of governments and attitudes that brought war about. He felt that German militarism was to blame for the war. He felt that, by defeating Germany, the Allies could make it clear that militarism was pointless and could ensure that perpetual peace would ensue.
President Woodrow Wilson did not use the phrase much, but he saw the war in this way as well. He felt that the settlement after the war could create a new world order that would remove the causes of war. This was why he issued his “14 Points.” He thought that the creation of better international laws, along with a League of Nations, could prevent future wars.
Thus, WWI was called the “war to end all wars” because there were people who felt that it would lead to the destruction of the sorts of governments and attitudes that caused war.