There were numerous factors that led to the collapse of the Chinese Empire in 1912, especially the growing power of European countries within and around China. The two Opium Wars fought between China and Great Britain played a role in the collapse.
The Opium Wars resulted in Great Britain taking control of Hong Kong and China losing territories to France and Japan. All of this led to an even greater resentment of the ruling Qing Dynasty by Chinese peasants. Another reason behind this resentment was the fact that the ruling family were Manchus from the north, while the majority of Chinese people are Han.
The growing foreign influence led to the Boxer Rebellion in 1900, a huge anti-foreigner movement led by Chinese peasants. The Qing Dynasty military eventually joined in the fight against the European powers but was unable to make any significant improvements in the situation. This eventually led to Sun Yat-sen's republican revolution in 1911, causing the last emperor of China, 6-year-old Hsian-T'ung, to step down in February, 1912.
After stepping down, Hsian-T'ung changed his name to Henry Pu-Yi. He was allowed to live in the imperial palace in the Forbidden City until 1924, when he was forced into exile.