This is because we are not in the Lord yet, as just noted [Section 21]. For example, if we give to the poor, help the needy, endow churches and hospices, support the church, our country, and our fellow citizens, teach the gospel, make converts, practice justice in judgment, honesty in business, and righteousness in our behavior, but still think nothing of evil like fraud, adultery, hatred, blasphemy, and such things, which are sins, then the only good deeds we can do are inwardly evil. We are doing them on our own behalf, that is, and not on behalf of the Lord. This means that we are inside them and the Lord is not; and any good deeds that have ourselves within them are all polluted by our evils and are focused on ourselves and the world.
However, the same deeds just listed are inwardly good if we are turning from evils because they are sins, evils like fraud, adultery, hatred, blasphemy, and the like. That is, the actions we are doing come from the Lord, and are called deeds done in God (John 3:19, 20, 21).
from Life/Faith, Section 24
Section 21: Published 3/30/2019:
This makes it very clear that to the extent that we turn our backs on evil deeds we are with the Lord and in the Lord; and to the extent that we are in the Lord the good deeds we do come not from ourselves but from the Lord. This yields the following general law: To the extent that we turn our backs on evil deeds, we do good deeds.