This old hymn by William Cowper shows the difference between law-based and gospel-based obedience. The law says, "obey and God will accept you." The gospel says, "God has accepted you; now obey."
No strength of nature can suffice
To serve the Lord aright:
And what she has she misapplies,
For want of clearer light.
How long beneath the law I lay
In bondage and distress;
I toil'd the precept to obey,
But toil'd without success.
Then, to abstain from outward sin
Was more than I could do;
Now, if I feel its power within,
I feel I hate it too.
Then all my servile works were done
A righteousness to raise;
Now, freely chosen in the Son,
I freely choose His ways.
"What shall I do," was then the word,
"That I may worthier grow?"
"What shall I render to the Lord?"
Is my inquiry now.
To see the law by Christ fulfilled
And hear His pardoning voice,
Changes a slave into a child,
And duty into choice.