Probably because it could be a mechanism that allow us to learn and never forget the lessons we get from our mistakes.
Just as scars on our skin that remind us of our past injuries, our mind remembers bad experiences so we truly internalize what we did wrong, and that way we don't make the same mistake again.