What is the relationship between faith and good works? Are good works necessary for salvation, even if it's only indirectly?
Article IV of the Formula of Concord takes up your question in great detail. When Scripture says that God saves people who “do not work” (Romans 4:5), and that he saves us “not by works” (Ephesians 2:8-9), “apart from observing the law” (Romans 3:28), “no longer by works” (Romans 11:6), and “not because of righteous things we had done” (Titus 3:5), etc., the answer becomes clear. Our good works are not “necessary for salvation” in any way, shape, or form—directly or indirectly, wholly or in part, before or after we are saved, etc.
But this doesn’t make good works “optional” for a Christian. One reason is that God still commands them. The Bible’s teaching of justification by faith alone does not turn the 10 Commandments into the 10 Suggestions. Through our good works, we worship and glorify our Savior God (Romans 12:1-3). We show that our faith is alive and well in front of others, who can’t see our faith but can see the actions that faith produces (Matthew 5:16). And through our good works we love and serve other people.
As Lutherans like to say, God doesn’t need our works, but our neighbor does. “Good works are necessary for salvation” would be a false statement. “Good works are necessary” is true–not for salvation, but for plenty of other reasons.