There were multiple factors that led to the demise of the Great Qing Dynasty:
1 - Backward Imperialism. The last rulers of Qing Dynasty saw themselves as divine rulers of a perfect nation, and saw European inventions (such as the musket and cannons) to be useless dirt. Therefore they didn't industrialise as the Japanese did (Meiji Restoration), and therefore they seriously lacked behind.
2 - Corruption. The Dowager Queen made a right mess of things when she took the real ruling power from her grandson, the true Emperor who wanted to industrialise. The Dowager Queen took military funding to build herself a grand Summer Palace, which practically stopped Chinese military development. Her backward ideologies influenced prominent government officials, who ignored the cries of starved commoners and sat behind their wall of riches, blissfully oblivious to the threat of Europeans.
3 - Foreign invasion. The invasion by Europeans was made easy by Qing Dynasty's backward military - the majority of the outnumbering Chinese Navy was sunk in less than a week (what use were wooden junks to steel monsters?). The British then subsequently supplied opium to China, and when the Qing government refused to trade opium, the Brits used it as an excuse to openly invade China, split Chinese territories in unequal treaties, committed atrocious things to the Chinese population and utterly undermined Qing rule.
4 - Rise of Nationalism. Intellectuals saw the only way to defeat the Europeans was to use European technologies against them, and hence the overthrow of the corrupt and out-dated Imperialist Qing Dynasty.