Some philosophers want to ground our duty to obey God’s commands in the need to show gratitude to God for all the goods God has done for us. I think there is something to that, but I want to point out a complication.
When someone has done something good for us, that generates moral reasons to do something good for them. But that is different from generating moral reasons to obey their commands. After all, being obeyed need not be good for the person issuing the commands. Imagine that you are on a ship along with someone who has already done many good things for you and your family. The ship is sinking. There is one last space left in a lifeboat. You start to push your benefactor into that space. Your benefactor interrupts: “Don’t! Get into it yourself!” In this case, it would be bad for your benefactor for you to obey their commmand, and obedience to this command would not, I think, be a right expression of gratitude. You might have other moral reasons to obey the command, such as that if someone is offering to make the ultimate sacrifice, you should not deprive them of that choice. But gratitude for past benefits is not a reason to obey your benefactor when your benefactor would not in fact benefit from your obedience.
So the mere fact that you are commanded something by your benefactor does not generate a gratitude-based reason for obedience. It is only when your benefactor would benefit from your obedience that such a reason is generated.
Now things get a little complicated in the case of God. It seems we cannot benefit God, as God has perfect beatitude. But as we learn from Aquinas’ discussion of love for God, it’s more complicated than that. There are internal and external benefits and harms a person might receive. Internal benefits and harms affect the person’s intrinsic properties in a positive way—think here of pleasure and pain, virtue and vice, etc. But there are external benefits and harms: when people speak badly about you behind your back, the loss of reputation is an external harm, even if you never find out about it and it never affects any intrinsic property of yours. Similarly, because friends are other selves, if x loves y, then benefits and harms to y are benefits and harms to x, albeit perhaps only external ones. Thus, we can benefit God by benefiting those that God loves, namely everyone.
So, when God commands us—as in fact he does—to love our neighbor, then our obedience to that command does benefit God, albeit externally. So it seems we do have a gratitude-based moral reason to do what God says. But notice that as far as the argument goes right now, that is not a reason to love our neighbor out of obedience to God. The reason to love our neighbor out of gratitude to God would remain even if God did not command us to love our neighbor.
But this isn’t the whole story. For, first, when we show gratitude to a benefactor by bestowing some internal or external benefits on them, gratitude seems to call on us to have a preference for bestowing those benefits that the benefactor asks us to bestow. Thus, the fact that some benefit to the benefactor is requested by the benefactor adds to the gratitude-based reasons for bestowing that benefit. And, second, it seems plausible that having one’s commands be obeyed is itself an external benefit—it is a way of being honored.
Thus, that God has commanded us to love our neighbor intensifies our reasons based on gratitude to God to love our neighbor. And even if God were to command something seemingly arbitrary and not in itself beneficial, like abstinence from pork, we externally benefit God insofar as we obey him. But in the latter case something stronger is needed than that: for the obedience to be a form of gratitude, it needs to be the case that on balance we benefit God through the obedience. That being obeyed is good as far as it goes does not show that being obeyed is on balance good. It is good as far as it goes for our benefactor to be obeyed when they say to go into the lifeboat, but it might actually on balance be better for them to be pushed into the lifeboat.
Thus there is a limit to how far this justification of divine authority goes. If we obey God out of gratitude, our reason for obedience cannot simply consist in the facts that God has commanded us and that God has bestowed great benefits on us. Our reason would also need to include the fact that on balance it bestows a benefit—an external one, to be sure—on God if we obey.
Is it the case that whenever God commands something, it always bestows a benefit on balance on God that we obey him? That initially sounds like a reasonable thesis, but we can easily imagine cases where it is not so. Consider cases where my disobedience to God would prevent massive disobedience by others. For instance, a malefactor offers me a strong temptation to disobey God, and tells me that if I refuse the temptation, then a thousand other people will be offered the same temptation, but if I give in, I will be the only one. Looking at how strong the temptation is, I conclude that if it’s offered to a thousand people, about 500 of them will succumb to it. Thus, if I obey God, there will be much less obedience of God in the world. Hence, my obedience to God actually leads to God being less honored and receiving less external benefit. But nonetheless I need to obey. Hence, the duty of obedience is not grounded in gratitude.
In summary: Normally, gratitude does give us moral reason to obey God. But if I am right, then the moral reason to obey God that comes from gratitude needs to include the assumption that it is good for God to be obeyed. And we can imagine cases where that assumption is false and yet obedience is still required.