When I was younger, I was told that these kinds of walls were purely defensive, and this view was certainly backed by fictional media like Mulan, the Abhorsen books and A Song of Ice and Fire.
Later on I was told they played more of an economic or physical deterrent role: they either acted as traffic controls and toll sites, or acted to make it less feasible for raiders to cross the border and bring plunder back with them.
I'm aware that it would be quite infeasible to man the entire length of a wall like this for any extended period of time, but I am curious to know: what would the daily operations of a wall like this look like? How was it employed? And what kind of role would it have played in the society of the people affected by it?