In Luther’s Freedom of a Christian, he explicates his view of the relation between faith and works. For Luther, good works are necessary–the natural outcome of (transformative) faith in Christ. But works are not meritorious for salvation, and should not be approached that way. Here’s what he says (as only he can):
If works are sought after as a means to righteousness, are burdened with this perverse leviathan, and are done under the false impression that through them one is justified, they are made necessary and freedom and faith are destroyed; and this addition to them makes them no
longer good but truly damnable works. They are not free, and they blaspheme the grace of God, since to justify and to save by faith belongs to the grace of God alone. What the works have no power to do they nevertheless, by a godless presumption through this folly of ours—pretend to do and thus violently force themselves into the office and glory of grace. We do not, therefore, reject good works; on the contrary, we cherish and teach them as much as possible. We do not condemn them for their own sake but on account of this godless addition to them and the perverse idea that righteousness is to be sought through them; for that makes them appear good outwardly, when in truth they are not good. They deceive men and lead them to deceive one another like ravening wolves in sheep’s clothing (Matt. 7:15).
But this leviathan, or perverse notion concerning works, is unconquerable when sincere faith is wanting. Those work-saints cannot get rid of it unless faith, its destroyer, comes and rules in their hearts.
And then Luther extols good works done freely, from a liberated conscience and a grateful heart, empowered by the transformational forgiveness of the grace of God through Christ:
Although the Christian is thus free from all works, he ought in this liberty to empty himself, take upon himself the form of a servant, be made in the likeness of men, be found in human form, and to serve, help, and in every way deal with his neighbor as he sees that God through Christ has dealt and still deals with him.