And what lead to that, just lucky or a complex sequence of events?
This is (understandably) a very hot topic of historical debate, and there is by no means a consensus in the answer.
One of the most significant works that deals with this question is Kenneth Pomeranz's The Great Divergence: China, Europe, and the Making of the Modern World Economy (2000). In this work, Pomeranz argues that up until even the late 18th century, Europe and specifically China were equal in production, productivity, industry, commercialization, technology, economy and more. They even faced similar ecological issues, leading all of Eurasia too be on equal footing. He argues that Europe (specifically north west Europe) only began to pull ahead due to the positioning of coal in Europe, which grew in importance as timber diminished. The 'New World' also relied more heavily on commodities from Europe than Asia, and East Asia's economy stopped growing due to the inability to continue to export to Indian regions with the rise in manufacturing and population. Historian Paul Bairoch particularly stresses this last point, as England's growing influence in India also prohibited China and Japan's expansion here. So in some ways, yes, it happened with the Industrial Revolution and was largely based on luck in resources.
However, these views are argued against extensively, and it would take forever to go through all of them. It is also important to note, that views that "Europe was better than the rest of the world" are very Eurocentric, with many global historians, such as Jack Goldstone and Arif Dirlik trying very hard to overcome these ideas that Europe was the center of the world at any time in history.