why was the great wall of China built

The Great Wall of China was built to protect the Chinese Empire from nomadic groups from the north, such as the Mongols. It was also used to control trade and immigration. The wall was built over a period of 2,000 years, beginning in the 7th century BC.