It literally was stupid though, because it was economically ruinous to build and impossible to staff or maintain. Enemy armies (most notably the Manchus of the 1600s) would periodically cross the wall in their raids, particularly through breaches created by local farmers who would scavenge from unmanned sections of the walls.
Yes, the walls around Beijing and a few vital passes were useful. But you didn't need to build across the entire country to benefit from a few defensible choke points.
The Great Wall is probably just the most famous in a thousand year history of ill-conceived physical border security measures. They're bad. They don't work good. Don't build these stupid things.