Germany's allies during World War I were Austria-Hungary, the Ottoman Empire, and Bulgaria. These formed the Central Powers and were opposed by the Allies, or the Entente, composed principally of Great Britain, France, the Russian Empire, and (later) the United States.
Though the evaluation of World War I as an imperialist war can be criticized as simplistic, I believe it is the best way of understanding what the war was really about and the deeper causes of it. The immediate cause of hostilities was the assassination of the Archduke Franz Ferdinand, the heir to the Austro-Hungarian throne, by a Serbian nationalist in June of 1914 in Sarajevo, Bosnia-Herzegovina, which at that time was a territory of Austria-Hungary.
Serbian nationalists, allegedly backed by Russia as part of a pan-Slavic movement, regarded Bosnia as part of their homeland and wished to free it from Austrian control. The belief on the part of the Austrians that Russia was behind the assassination led to a declaration of war. Alliances were already in place, meaning treaties had been signed in which each country had agreed to support its fellow signatories in case of war. Given that Germany was an official ally of Austria-Hungary, Germany thus declared war on Russia as well, and France and Britain, being allies with Russia, entered the conflict on the Russian side against Austria-Hungary and Germany.
For those not familiar with the system of alliances that had dictated the conduct of European (and other) countries for centuries, all of this may sound contrived and artificial. The question that must be asked is always "Why were such binding alliances formed in the first place?" What did the signatories to such treaties have to gain by signing them and by becoming involved in large-scale wars when there was ostensibly no direct threat to their own countries?
The answer is basically that at this point, 1914, the major European states were all involved in massive competition for power and resources. Germany had become a unified nation-state only forty-three years earlier. For centuries, Germany had been a patchwork of small, independent states loosely unified by a kind of quasi-mythic concept of ethnic solidarity known as the Holy Roman Empire. When these states (apart from Austria, which retained its separateness as co-leader of its own multiethnic empire) were unified, the balance of power in Europe was altered. Britain and France saw a new danger in a powerful state in the center of Europe that was prepared to compete with them for colonies and resources outside of Europe as well as to influence and control the smaller, less powerful European countries.
In addition, Britain, France, and Russia had long had their hands in the weakening Ottoman Empire, the so-called "sick man of Europe." Germany, however, had recently formed an alliance with the Ottomans, essentially displacing Britain as the principal European power making a client-state of the Ottoman Empire. In addition, the German-Ottoman alliance threatened Russian dominance in Central Asia and the all-important trade routes to Asia, including, of course, the recently completed Suez Canal. These routes were crucial to the British, French, and Dutch imperialist systems. Therefore Britain, France (which had been defeated in the Franco-Prussian War in 1870 and was itching for revenge against the Germans), and Russia had made common cause against Germany. Germany, in ethnic solidarity with Austria (threatened, as it felt itself, by the assassination of its heir at the hands of a Russian-allied national movement), was ready to get its licks in, to put it colloquially, against the British, French, and Russians.
Germany felt it had centuries of catching up to do in order to bring itself to the same power level as other countries, which had already been unified nation-states for hundreds of years. The Germans believed—to some extent, correctly—that the other powers had always wanted the German-speaking peoples to remain fragmented and disunited. Germany also wanted to manipulate the moribund Ottoman Empire, completing its plans for a Berlin-to-Baghdad railway and cynically taking advantage of nationalist Turkish sentiments to establish its own colonial control over much of the non-Turkish territory of that Empire. All of these were factors that led to Germany's entry into the war and the tragic and horrific events of 1914 to 1918.