In this case, city means a metaphor for an average person, a mediocrity living among other members of the society, who are not supposed to care about him. Prufrock understands it very well, as the last lines show:
“We have lingered in the chambers of the sea
By sea-girls wreathed with seaweed red and brown
Till human voices wake us, and we drown.” (lines 129-131)
His imagination allows him to “linger the chambers of the sea” – the world of imagination, ability to communicate with its inhabitants and not be ridiculed, while the call of human voices remembers Prufrock about his real or imagined deficiencies. He cannot step beyond the frontiers he has drawn himself between his room and the city outside, so it is even not matter much, whether Prufrock really walks around the city or not.
If to return to the question about the function of the city metaphor in the particular poem, the image of the city stands for the hostile world outside, in front of which he has to admit his own inability. The author has managed to sustain the city metaphor in his poem so that it resonates with the feeling of loneliness and imperfection any human being has felt, so that readers can perceive the author sharing emotions any of them has felt at some instance of his or her life.
…