First to clarify I do not mean shaming others. I mean a personal sense of shame.
Shame in third-world societies (like the one I have lived in for the last 15 years) serves many important functions.
In my case, it is a matriarchal culture. The worst thing that can happen to a person is that your mother would feel ashamed. So people go out of their way to not do shameful things like stealing, lying, being disorderly intoxicated, and other socially hostile activities. I find that it is effective at keeping social order, and one of the worst insults is to imply that someone was ill - raised.
So what function did shame serve in that society?