A Bosnian Serb nationalist assassinated Austria-Hungary's heir to the throne, Archduke Ferdinand, and his wife, during their visit to Bosnia in June of 1914. Austria-Hungary ruled Bosnia and many other Slavic countries at the time, and some people wanted to free these countries from Austrian control. In reaction to this, Austria-Hungary gave Serbia an ultimatum, making several demands, some of which were pretty outrageous. Serbia complied with most, but not all of the demands. The more radical members of Austria's government favored, and eventually got, war with Serbia.
But a lot of other things escalated this incident to the level of being a world war. European powers had formed a series of alliances by 1914, so that no one power could go to war without its allies, and enemies, getting involved. Russia had long supported Serbia and the independence movement of Slavic nations in southeast Europe. When Serbia came under attack, the Russians got involved, declaring war on Austria-Hungary. Germany and France, allied to Austria-Hungary and Russia, followed suit. Britain got involved when Germany violated Belgium's neutrality.
Also, the trend in Europe at this time among military commanders was to make war plans. These plans followed strict timetables for mobilizing and moving an army into battle. Military commanders feared that if their enemy put their plan into action and mobilized first, they would be ahead in the war, and would most likely win. So as the powers of Europe were debating war in the summer of 1914, commanders were urgently trying to persuade their government's leaders to mobilize before their enemy did.
There were other factors too, like intense nationalism and ethnic hatred, which existed in Eastern Europe between "Teutonic" peoples (Germans, Austrians) and Slavic peoples (Russians, Serbs, Poles, Czechs, and others), as well as between the French and Germans, who had fought for centuries. A major motivation for France to go to war was the recovery of the provinces Alsace and Lorraine, lost to Germany in a previous war. Also, militarism and arms race; nations like Britain and Germany were rapidly building their armies and fleets in direct competition with each other. They were both really spoiling for a fight, and the general feeling in Europe at this time was that a war might be a good thing for the young generation.