Lots of the answers here focus on relatively short-term or 'circumstantial' causes. Historians tend to distinguish between the waves and the tides - the superficial to-and-fro of human affairs, and the deep underlying forces that drive them this way and that. I'm going to focus on the tides here...
1. European cultures (and the USA too) were dominated in the 1890s and 1900s by ideas that masculinity (in fact, the whole of society) was in decline and needed to be 'saved' from luxury, comfort and idleness - many people proposed that warlike activities (for example, the Boy Scouts, or mountain hiking) might start that process, but that a genuine war would really help.
2. European cultures (and the USA too) were full of talk about how war was 'swift' and 'dashing' - it would be about planes and cars and machine guns - so they felt that they could start wars, and that they'd be low-risk and over relatively quickly, whoever won them, so lots of people were relatively cavalier about advocating war in general.
3. European cultures (and the USA too) were obsessed with the idea that society was full of racially degenerate 'dross' wrecking the gene pool, and that a war might be a great way to clear that out, so lots of people (doctors, trade unionists, landowners, nationalists) promoted violence and struggle as good in and of themselves.
4. So a lot of the 'causes' of the war were actually mentalities and attitudes that permitted or encouraged idiocy, rather than geo-political conflicts, because in cultures where there are geo-political conflicts, but no idiotic ideas, wars don't happen.
5. Most European states apart from France, Britain, Scandinavia, Belgium and Holland were shambolic attempts to form states out of diverse and contradictory social, economic and cultural groups that realistically had little respect for each other and little in common with each other, and this meant that violence in those societies was often an inbuilt part of the political process.
6. France, Germany, Britain, Belgium, the Netherlands and the USA had all come to rely on violence very extensively in their colonial enterprises (for example, the colonisation of North America), up to and including the use of genocides as a policy tool, and so they too tended to view violence as a perfectly reasonable way of organising the world.
7. Humans can be so stupid sometimes.
8. There were complex geopolitical conflicts and patterns of alliance, but in many ways, these did not so much 'cause' the war, as give it the shape and form that it took.
9. So by 1914, the 'gate' to warfare was open, wide open, and any one of a number of more momentary crises could have sparked some sort of conflict.