The alliance of World War I Allied Powers was formed by France entering into a military alliance with Russia, and then bringing Great Britain into the pact between the three countries called The Triple Entente in 1908. The United States joined forces with the Allies in the spring of 1918.
In the late 19th century and the early 20th century, complex interplay of international politics resulted in military treaties. Being part of a military alliance meant that if one country was attacked, the rest of the alliance members had to defend that country.
In the second half of the 19th century, Germany was unified under Prussia from its former self as a confederation of small countries. Germany also went through rapid industrialization, and with its new steel and weapons, it attempted to overturn the balance of colonial powers in its favor. This bothered the old empires of the British and the French. Germany kept France isolated in Europe. One of the moves against France on the part of Germany was creating The Three Emperors' League, which comprised Germany, Austria-Hungary and Russia. The individual who inspired all these policies was Otto von Bismarck.
However, Kaiser Wilhelm II dismissed Bismarck. He drove Russia from The Three Emperors' League, and so France seized the chance and signed a military treaty with Russia, which Great Britain also joined. Serbia had a treaty with Russia. When, after the assassination of the Austrian heir by a Serbian militant, Austria declared war on Serbia, Russia had to go to war with Austria. Austria was a part of the Central Powers, also comprising Germany and Turkey. Thus, all countries that were Allies went to war with all the countries in the Central Powers.