The Reason of Shame

Hi coaches, do you have an answer around the reason of shame? I dont mean why shame in the sense of looking at the cause of it, but rather its purpose, its utility. Said otherwise, how is shame for us?

If I think to the ancestors, I guess shame was meant to avoid rejection from the tribe and thus being abandoned, but now these days…we often speak about all the issues shame creates, but what is its utility in our lives, if any?

How can we make use of the information it conveys, can we use it at our advantage?