The immediate cause of the 1st World War was the assasination of the heir to the Austrian-Hungarian throne, Archduke Franz Ferdinand in Sarajevo. His assasination set off a chain of events that would set Europe aflame. But the conflict had been years in the making. The Russian, British and the French Empires were wary of the German Empire’s rise to power. As a result they had been building up their armed forces for quite a while.
All it needed was a spark. The spark came in 1914 in the form of Archduke Franz’s assasination. Since Germany was an ally of Austria, it declared war on every other country – Britain, France, Russia etc, that had declared war due to Austria’s declaration of war on Serbia.
For further reading check the following articles: