It isn’t a universal view that the war was “inevitable”. After all, Europe had navigated many crises in the early 20th century without a general war among the great powers (e.g. Morocco, the Balkan crises and the Naval arms race). So there was reason to believe in the July crisis that a solution would be found without general war breaking out. Further, it would be wrong to say that Europe fell into war as if by accident. On the contrary, decision makers were aware of what they were doing and retained control over events. There were exits all over the building.
But the forces at play led to a high degree of fatalism among Austro-Hungarian, Russian and German key players, to the point that war was considered “inevitable” by enough people to drive the chain of events. Under this mindset, the key decision was when war would best suit each nation’s strategic interests, considering the projected strengths of rivals.
Germany takes particular responsibility for the unfolding of events, given its great power ambitions and fear of encirclement by France and Russia. Germany gave unconstrained encouragement to Austria-Hungary after the assassination of Archduke Franz Ferdinand (the blank cheque), largely out of fear of the consequences for its own strategic position should its major ally need to fold in the face of potential Serbian and Russian interests. Austria-Hungary was in decline and, encouraged by a hawkish Chief of General Staff (Conrad von Hotzendorf), sought war with Serbia to counter its own perceived vulnerability to Serbian ascendancy - the blank cheque was just the encouragement it needed. And Russia could ill afford to back down, having done so in the earlier Balkan crisis and facing potential loss of prestige in an area it considered a key strategic interest.
All three countries therefore had incentives to pursue high risk strategies that led to a general war. The final piece in the puzzle, to drag Britain and France into the conflict, was the dominance of German military planners over decision making. Moltke in particular effectively vetoed a concept of attacking only Russia; the German plan in particular was considered highly inflexible, partly due to its dependence on rail timetables, and the operationalising of the Schlieffen Plan meant an attack on France was required regardless of the diplomatic situation.
This situation and the incentives relating to Germany arose for a number of reasons.
In this climate, the probability of a general war was high but not inevitable. However, it is telling that only after the Second World War when German great power ambitions were finally ended did Europe enjoy relative stability again. Therefore, perhaps the main driver (along with the fatalism and lack of vision among the July decision makers), is the nature of German strategic aims in the early 20th century, under an unchecked authoritarian regime at the geographical centre of a number of empires in decline.
“The War That Ended Peace” by Margaret MacMillan is probably one of the better explorations of the key decision makers in the lead up to July 1914, if you are interested in further reading!