There were many causes of World War I. Historians often point to three major causes.
Nationalism. This helped to cause the war in at least two ways. First, it tied the Germans and Austrians on the one side, and the Russians and Serbs on the other, together in strong alliances based on ethnicity. Second, it led to Slavic nationalist upheaval within Austria-Hungary. This led to the killing of the Archduke Franz Ferdinand, which set off the war.
Militarism. There was a cult of military power in many European countries at this time. Countries felt that their military strength was a source of national pride. This was particularly strong in Germany as the Kaiser strengthened his military in an attempt to get Germany its “place in the sun.” This glorification of military strength made war more likely.
Imperialism. There was a great deal of competition between countries for empire. They felt empires were sources of national pride as well as important economic assets. This competition helped to create bad feelings that led to war.