Regret is an essentially human emotion. We make mistakes. If the mistake is without serious consequence we may just feel foolish; if it shows us as less than ideal we might feel shame; if it causes others to suffer we feel guilty; if it contradicts the law of god we feel a sense of sin. This is an overly simplistic taxonomy of what might be called the negative social sensations, in contrast to such positive sensations as friendship, compassion and love.
Social sensations provide the basis for religion. In the Eastern religions, our fate (karma) in this life and in later reincarnations is determined by how well we have followed the way of justice (dharma). In the monotheistic religions that come from Abraham, however, justice has a personal edge. Wrongdoing becomes a sin against God’s law and incurs his wrath.