Walls don't have too good of a history.
We all know about the Berlin Wall, and how that turned out. Other walls (planned or executed) with mixed results - the US border wall, the Israeli's wall, The Maginot Line.
One notable thing before I continue. Building walls around communities to keep the other guy out (especially when that other guy is a member of a "dangerous" or "undesirable" group) is not unique, and is in fact prevalent here in the good old US of A.
All that being said, the building of walls around certain neighborhoods in Iraq is just another thing to try because they are desperate that nothing is "working" (and by working I mean getting them to stop killing each other and us, and getting some semblance of governmental effectiveness going). The deeper problem is that it was known going into Iraq that these people (Sunni's vs. Shiites) were not going to get along. You cannot shove a gun into someones face and tell them to get along or else.
The faith of the Administration (and those who supported the war) felt that if we just dropped enough bombs, or killed enough bad guys, the people in Iraq would eventually see how great Democracy is, and would come around to our way of thinking. Overwhelming military force would do the trick. Culture, ethnicity, religious belief? None of it matters if you use enough force.
Other voices that were ignored, predicted the mayhem now occurring (see General Shinseki's comments below - comments that great military strategist Paul Wolfowitz called "wildly off the mark"):
"I would say that what's been mobilized to this point -- something on the order of several hundred thousand soldiers are probably, you know, a figure that would be required. We're talking about post-hostilities control over a piece of geography that's fairly significant, with the kinds of ethnic tensions that could lead to other problems. And so it takes a significant ground- force presence to maintain a safe and secure environment, to ensure that people are fed, that water is distributed, all the normal responsibilities that go along with administering a situation like this."
Of course, the Administration would like you to believe that we in no way could have predicted the events on the ground, but General Shinseki's prediction seems pretty darn accurate (and why? It was based on EXPERIENCE and STUDY of war in all of its facets, not some pie in the sky dream of how he thought the world SHOULD be)
If you want to know why they won't get along for awhile, you need to read Paul Rieckhoff's great book "Chasing Ghosts: A Soldier's Fight for America from Baghdad to Washington".