What ultimately triggered the conflict was, of course, the assassination of Archduke Ferdinand of Austro-Hungary by the Serbian nationalist Gavrilo Princip. But the immediate cause of World War I was the complex system of diplomatic alliances that had been painstakingly constructed over the course of the previous century.
Ever since the defeat of Napoleon, European powers had been convinced of the benefit of mutual alliances between nations. They believed that such agreements would make it harder for one nation to cause as much havoc and upheaval in Europe as Revolutionary and Napoleonic France had done. The thinking behind the alliance system was that it would provide a balance of power in Europe. It was believed that large states would be reluctant to attack smaller ones if they were under the protection of other large states under this system.
In theory, this seemed the perfect solution to the massive upheaval and disruption caused by French armies from the Revolution onward. In practice, however, the system of alliances ignored the facts that the precise boundaries of nations could not always be determined with any degree of accuracy and that ethnic nationalism often transcended borders. So, in 1914, when Serbia found itself subjected to impossible demands by Austro-Hungary and its German allies, it was inevitable that the Russians would intervene on behalf of their fellow Slavs. Soon, other nations piled into the incipient conflict, fulfilling commitments to mutual assistance treaties that they never thought would come to fruition.