There is different version why British Empire took control over Hong Kong.
- Britain helped China to eliminate pirates in South China Sea. As a sign of appreciation China give control of Hong Kong to Britain.
- China was weak. Britain, Germany, Russia, France and Japan were willing to partition China. In order to avoid that China gave Hong Kong to Britain and Britain sponsored China.
Maybe there are more variants, I do not know.