I grew up Catholic and though that the practice of "confession," telling one's "sins" to a priest, was a way of shaming myself, admitting I wasn't good enough. When I learned about research on therapeutic presence, psychological safety and "getting things off our chests" to feel integrated and whole again, it occurred to me that this was the ideal role that confession could play.
Pre-internet and living in small villages, who could you go to for a loving listener if you had done something which you felt terrible about and which betrayed your highest values ("a sin")? Telling your peers, you might be ostracized from the community, which would mean death. I don't know the history behind this practice, and I know personally that the practice of confession didn't always live up to this idea. But I think maybe this was the ideal purpose.