Works righteousness
In Luther's day, it was the ancient Greek philosopher Aristotle who summed it up, and whose message was so widespread.
Aristotle said, "We become righteous by doing righteous deeds." We become righteous by doing righteous deeds, or we become just by doing just acts. It was self-help "fake it till you make it" message.
So, if you work at outward righteous acts and keep doing them, it claimed, you will actually become a righteous person. And for years Luther lived by the maxim "We become righteous by doing righteous deeds."
As a monk, he desperately did all the righteous deeds he could imagine -- fasting, praying, pilgriming, monking, and what he slowly came to realize was the dream of becoming truly righteous by some simple change of behaviour was just that, an elusive dream holding its reward ever just out of reach.
It consistently promised righteousness without delivering it, all the time exacting a heavier and heavier behavioural demand.
In other words, by dangling the hope of becoming righteous before him, while repeatedly giving more deeds to do, that idea gradually enslaved him. Worse, while doing all those outward acts of righteousness he found it wasn't making him upright in heart, full of love for the Lord.
Quite the opposite, as he's doing all these apparently he thinks righteous acts, he found resentment snowballing inside him for the God who demands so many deeds. Trying to sort himself out and become righteous by his own efforts was driving him deep into slavery, despair, and hatred of God.
In 1515, Luther delivered a series of lectures on Paul’s letter to the Romans during which his new understanding of justification would develop; he was especially challenged by Romans 1:16–17. Contrary to a works righteousness based on or aided by a person’s own efforts or good merit, Luther would argue from plain scripture that righteousness could only be imputed to person by God on the basis of faith.
Now Luther's understanding of faith-based justification—the process by which people are made righteous in the sight of God—is and will always be a direct result of faith, not works.
Righteousness could not be earned by a person’s own merit. Luther was heavily influenced by the writings of Augustine of Hippo, especially when it came to his understanding of the righteousness of God.
The Law is the divine commandments of God which convict one’s conscience of sin, and the Gospel is the good news God’s grace revealed in Jesus Christ. Because the human will is, according to Luther, in bondage due to sin, all people are incapable of fulfilling the Law. The Law, however, remains useful for revealing this deficiency within human hearts as well as the need for grace—this is the chief function of the Law. Luther also believed the Law is useful both as a restraint against rampant sin in the world. The Law was not intended nor able to justify. The Gospel alone is able to justify, proclaiming not what we are to do, but what God has done for humanity.