It was made to keep invaders out.
Although it's not tall enough to actually keep people out.
It is designed to slow any attacking force. (Because the attacking force would have
a difficult time getting resources and horses over the wall)
It's also considered a very ambitious engineering quest because at the time, it was such big deal to build such a long wall (kinda like the pyramids) and the people who worked on it were worked until they basically died, from cruel handling, exhaustion etc.