The wall and gates of a city were a status symbol, telling the world how good your leader was. But they were obviously important for the defence of a city as well. For example, in 272BC renowned warrior king Pyrrhus of Epirus was making a name for himself through the use of war elephants. But when he tried to sneak one through the gates of Argos the elephant got stuck, foiling Pyrrhus' plans for a surprise attack. This cost Pyrrhus his life - an old lady, alerted to the attack, threw a roof tile from a window, hitting Pyrrhus on the head and killing him. But then again, this was the guy that has the saying "Pyrrhic victory" named after him because of his habit of winning great victories at an unacceptable loss of life.
From Wikipedia: A Pyrrhic victory (/ˈpɪrɪk/PIRR-ik) is a victory that inflicts such a devastating toll on the victor that it is tantamount to defeat.