Allah opened for Adam the doors of repentance and legislated for him and his offspring the method of repentance after sinning as a form of reformative legislation.
As long as the human being is given a choice and possesses desires, he will inevitably err and follow his desires. He might lie, backbite, steal, take bribes, take inheritance unlawfully or even kill. If Allah had not opened for His servants the door of repentance, they and their whole community will become miserable. The believer will be miserable due to the disobedience of the disbeliever, wrong-doer and all those who stray from the directives set by Allah.