The Great Wall of China was primarily built for what purpose?

The Great Wall of China was primarily built for defense and protection against invasions by various nomadic groups and military forces. It was also used for border control, regulating trade and immigration, and as a symbol of the strength and power of the Chinese empire.