At a surface level, the assassination of Archduke Franz Ferdinand can be seen as the main cause, but this was just the catalyst for bubbling tensions which would have resulted in a war regardless.
There were a number of underlying causes of the war. The first being the imperial nature of many European powers at the time which encouraged expansionism. Secondly, an arms race was going on where a number of nations were building their militaries and experimenting with new technology. There was an eagerness among some to put these new weapons to practice in war. Thirdly, since Germany was growing at a faster rate than other European powers, there was a general feeling that a war would have to be fought to contain Germany's power. Finally, as mentioned above, the alliances and treaties that were invoked after the assassination of Franz Ferdinand finally caused the war.