The Chinese knew about building walls by the seventh century B.C. The Warring States Period began in the fifth century B.C. It ended in 221 B.C. During that time, states build huge forts to protect themselves from other kingdoms. But they weren’t just fighting each other. They were also being attacked by nomads from just north of present-day China.
The biggest threat was the Xiongnu. Their empire stretched beyond the borders of modern-day Mongolia. They lived in the desert. These tribes didn’t have the same basics and luxuries found in Chinese society. So the Xiongnu raided and looted Chinese cities. They were seen as very dangerous. That’s why the first Emperor of China, Qin Shi Huangdi, had a great wall built to protect his empire from Xiongnu attacks.