in history lesson, alliance system usually credited as one of main reason that caused the war, but rarely it's explained how the alliance it self formed. reading history little back before WW1, you will found country that later allied in WW1 was arch-nemesis for hundred of years previously.
like, take central alliance for example. Prussia and Austria is fighting war at each other over German speaking world dominance since HRE era. While Habsburg Austria and Ottoman has fighting over Balkan and Mediterranean dominance since like those empire formation.
situation isn't much better either for allied powers. France and Britain are in each other throat for... eternity at that point. and UK and Russia is fighting war over colonial dominance in Central Asia. UK and USA relation isn't exactly good considering UK supporting confederacy in civil war.
so. how the alliance formed? what the cause those alliance? what even that lead to those country decision to made alliance setting aside their past grudge?
Ho boy. Get your corkboard, pushpins, and string ready, because yes the foundations for the formation of the Triple Entente and Triple Alliance is a bit of a doozy to unravel, but it can best be summed up with the term "Realpolitik" or pragmatic politics, where political realities of the present take priority over historical relations or ideological alignment. But before we get to the Alliances of the late 19th Century, we need to start with the Congress of Vienna, signed in the aftermath of the Napoleonic Wars.
PART I
Congress of Vienna to the Franco-Prussian War
The Congress of Vienna was a political conference to reconstitute the European political order in the aftermath of France's defeat in the Napoleonic Wars, and was essentially a redrawing of the map and political climate of Europe to maintain a status quo through maintaining a balance of power between the Great Powers of Europe (and also, to protect the institutions of the European Monarchies from the liberal ideas of the French Revolution). The general idea was to create a political and military balance of power throughout Europe between the Great Powers, where one Power is wholly unable to dominate all other powers, in an attempt to avoid a situation like France's domination of the Continent throughout the Napoleonic Wars.
Major decisions made by this Congress included the establishment of a German Confederation in place of the defunct Holy Roman Empire, a general expansion of Prussia's borders within the German Confederation, Russia gaining the Duchy of Warsaw, establishing new borders for Italy, keeping the region divided and unable to politically challenge the Great Powers, with Northern Italy in particular under Austrian domination while Piedmont-Sardinia nominally fell under a French sphere of influence. This Concert of Europe generally upheld the status quo as designed, but not without its challenges, with the three major tests of the status quo being the Revolutions of 1848, the Crimean War, and ultimately the end to the Congress, Italian and German unification.
In 1848, the first major test of the Concert of Europe took place in the form of major revolts and revolutions all across Europe through 1848 in France, the German Confederation, Prussia, Austria, Sardinia-Piedmont, with minor revolutions also taking place in Sweden, Denmark, and Switzerland. The goals of the revolutions varied but were generally aligned with the ideals of the French Revolution, that is an abolishment/curtailment of monarchies, the adoption of a constitution, and public representation in government. This wave of revolution resulted in a wave of change to the European status quo, including the overthrow of the French Monarchy and the establishment of the Second French Republic, an attempt to politically unite Germany, creating a short-lived German state with its capital in Frankfurt, and the adoption of a Constitutional Monarchy in Sardinia-Piedmont. Austria conceded to some Revolutionary demands with the abdication of Emperor Ferdinand I and the abolition of serfdom in the Empire.
In the end, the more drastic political changes to Europe were reversed. The Second French Republic quickly fell and was replaced by the Second French Empire under Napoleon III, Napoleon's nephew. The German Empire was quickly stamped out by Prussia by forcing the Frankfurt Parliament to dissolve in 1849. Attempts in Italy to unify the country through revolution, supported by Sardinia-Piedmont, were crushed by Austria and the Two Sicilies. The balance of power between the Great Powers held, but the social and cultural status quo in Europe was over.
In the early 1850's, Russia was positioned to expand its borders at the expense of the declining Ottoman Empire. After a Russian victory against the Ottomans in 1829, where Russia gained territory in the Black Sea and forced open the Dardanelles to commercial shipping, Russia was in a position to expand further across the Danube River and into the Balkans through present-day Romania and Bulgaria, which would greatly upset the European balance of power in favor of Russia. Originating between a conflict of interest between France and Russia over patronage and protection of the Ottoman Empire's Christian population, Russia went to war against the Ottoman Empire again in 1853, with France and later Britain entering the war against Russia not so much as to protect the Ottoman Empire, but to check Russia's ambitions for expansion into the Balkans, with Sardinia also committing small amount of soldiers to curry favor with Britain and France. The war ended with a Coalition victory against Russia, checking its ambitions for expansion and maintaining the balance of power on the continent.
The last major events that put an effective end to the Congress of Vienna were the Unification of Germany and Italy under Prussia and Sardinia-Piedmont respectively. I wrote extensively before on Italian Unification in this answer over here, but to put it short; Sardinia-Piedmont secured French support in the Unification of the Italian peninsula under Sardinia-Piedmont. After Sardinia warred its way across Italy and patched Italy together through a series of wars against Austria, a hostile takeover of the Two Sicilies, and a series of plebiscites in the central Italian states led to the foundation of the Kingdom of Italy in 1861, ending with the capture of Rome in 1870. In Germany, Prussia was also busy warring its way across Germany in an attempt by Foreign Minister Otto von Bismarck to unify Germany. After victories against Denmark, Austria, and his crowning achievement, victory in the Franco-Prussian War, Bismarck's creation, the North German Confederation successfully persuaded the southern German states to join in the war against France. With both unifications complete, Europe had two new Great Powers on the board, and with German and Italian victories against Great Powers like France and Austria, the balance of power was shattered in Europe, necessitating a new order to maintain peace on the Continent.