Mercy is from the Hebrew word ‘hesed’, which means to restore to a position such that it is as if what went wrong never did.
In several Nations, just as former President Obama did just before leaving office, offenders can have their sentences commuted or reduced. In some cases, condemned criminals are set free from death row.
When the purpose in the life of an individual is very strong and relevant to God and He sees a strong determination to actualize it, He uses His Sovereignty to overlook some rules and allows purpose to take precedence over law.
He did it with Ruth.
He suspended the law that prevented any descendant of a Moabitess from entering the temple of God until the 10th generation. But David was a king and a great grandson of Ruth. David entered the temple and ate the showbread when he was hungry and God ignored his breach of statute. In this book you will see it at play in the life of another great woman in the Bible.