In scriptural terms, justice is the unchanging law that brings consequences for actions. Because of the law of justice, we receive blessings when we obey God's commandments. The law of justice also demands that a penalty be paid for every sin we commit.
When the Savior carried out the Atonement, He took our sins upon Himself. He was able to “answer the ends of the law” (2 Nephi 2:7) because He subjected Himself to the penalty that the law required for our sins. In doing so, He “satisfied the demands of justice” and extended mercy to everyone who repents and follows Him (see Mosiah 15:9; Alma 34:14-16). Because He has paid the price for our sins, we will not have to suffer that punishment if we repent (see D&C 19:15-20).