Very very complicated.
After the industrial revolution, all the major powers had new toys to play with: engines, airplanes, rifles, bombs, gas, advanced concrete, ironclad warships,...
Everyone kinda though "well if I don't attack, the others probably will someday".
All powers felt like they were the biggest fuckers in the room. And they all gave guarantees to their allies: if you go to war, we will help!
That was the general atmosphere, very tense and ready to play, since nobody expected how disatrous these new weapons would be.
So, in these tense times, the Germans were allied with the Austrian-Hungarians.
In 1914, Serbian guy in Sarajevo killed Franz Ferdinand, who would have inherited the throne.
Following this, the Germans gave them a guarantee: if you are in a war, we will help.
Soon after, Austro-Hungary set an ultimatum to Serbia: apologize, give money, etc.
Russia decided to give guarantees to Serbia, like Germany gave to Austria.
Serbia decided "fuck this ultimatum" and mobilized their tropps.
Austria mobilized their troops. Austria declared war and took a few shots at Serbia, prompting Russia to mobilize to fulfill their promises to Serbia.
So Germany said, hey Russia, fuck off or we will have war, and by the way, France, you stay neutral or we will fuck you over as well.
Both of them told Germany to fuck off and mobilized their armies. Germany mobilized as well, and declared war on Russia.
They also allied with another force, the Osmanic Empire (Turkey).
Meanwhile, the British got nervous and strenghtened their fleet while the mainland was brooding.
They decided they would help France if it came to war.
Since France ignored the request to stay neutral and instead got their troops ready, Germany decided to take out the biggest threat first and declared war on France.
This resulted in an ultimatum from the British to Germany, which Germany ignored.
Therefore, the British declared war on Germany.
That's the basic gist of how it started