We obey God out of gratitude for the grace we have received, not as a means to earn our salvation.
While salvation is indeed by grace alone, our obedience is the natural result of that grace at work in our hearts. Ephesians 2:8-10 clarifies that we are saved by grace through faith and that we are created for good works. Thus, our obedience serves as evidence of our faith and love for God, showing that we appreciate His unmerited favor towards us. As Christ's followers, obeying God's commands is not an attempt to earn His love, but rather a response to the love He has already shown us through His Son. Our good works are the fruit of a transformed life, which He has set forth for us to walk in.
Commentary