The idea of having a unified organization of nations designed for peacefully resolving disputes and other such things among countries was first probably first proposed in the late 18th century by a German philosopher named Immanuel Kant. He proposed that a league of nations could be used to control conflicts that would occur between various states in the world and to also promote peace. It would be more than a hundred years before such an idea would become reality.
In the early 20th century, two "power blocs" had emerged in Europe and these would form the basis of who fought who in World War I. WW I saw casualties as never before due to the fact that industrial nations were fighting and putting their production resources into making war materials. With this increase in the devastation caused by war, anti-war feelings grew across the globe. There was a great desire to prevent any such things from happening again as many people considered World War I to be the war that would end all wars.
In an address to Congress on January 8, 1918, President Woodrow Wilson included fourteen points that would later come to influence the treaty that would eventually end World War I. The last one listed is a reference to the formation of a league of nations. It's interesting to note that "covenant" is used here to refer to the agreements that must be made between the nations instead of "treaty" or "agreement" in its place.
These Fourteen Points eventually led to the formation of the League of Nations.