I don't know if anybody else has already mentioned this or not, but God didn't even hold himself accountable to Moses' precept as is recorded in Deuteronomy chapter 24.
In case anyone else wondered why God doesn't always seem to go by the same rules He gives mankind, Though its something people might just wonder in passing, I think its a pretty important to address, because a byproduct is that the nature of God is questioned when we start to think like this. So, I would add my 2cents in clarifying the matter if I can. Hope that's ok.
The law was not given TO God.
It was given BY God.
It was given to people, BECAUSE they were sinful.
Many freedoms of choice are given to adults that are not given to children.
We do not allow children to wander off unsupervised, to go talk to strangers, to eat and taste and try anything and everything they want, to stay up as late as they think sensible etc.
Why? Because they are just children. They often cannot fully understand the dangers and risks, the implications of actions and choices, or do not know what is good for them in the long term. In the same way, the Lord has had to hem His children in with rules like - dont murder!
Can we really comprehend the immense depths of our (humanities) ignorance and depravity, when the Lord had to give Moses a law, had to literally command us, and even had to threaten us with the death sentence in many cases, to stop us from carrying on doing things like...
Worshiping Idols...
Sleeping with other people's spouses...
Stealing...
Murdering...
and on and on it goes.
Yes. That basic level of morality was lacking, and the commands of the law were desperately needed.
On top of that, God had to add a ton of really harsh consequences for disobeying, along with some very sweet blessings if people complied. THERE IS A LOT OF IT THERE. It all was really needed. Humanity was, and is, so very depraved. Every intent and thought of their heart was evil.
Yet even the law, with all the curses and the blessings, as glorious and good as it was, wasn't enough to stop people sinning, it simply stifled it somewhat.
So, in light of the depths of the depravity that motivated God to give His people the law, would we want to imply that God also needs, or has ever needed to come under that, or any other, law?
Does He need a law to teach, to remind, to encourage, even to threaten, and to compel Him not to do wickedness? Of course not! God cannot, and has never even begun to desire to, sin!
The law was commanded by God and given to sinners:
To deter us from acting out sinful desires.
To teach us what God demands from His people.
To reveal the depths of our depravity,.
To show us our need for a Saviour.
1 Timothy 1:9
knowing this: that the law is not made for a righteous person, but for the lawless and insubordinate, for the ungodly and for sinners, for theunholy and profane, for murderers of fathers and murderers of mothers, for manslayers...
So, clearly, God has never personally needed to follow any commands, or a law. He never will.
However, for a limited time in history, God did willingly and deliberately subjected Himself to being under the law, when He came to earth as the Son of God. It was only for the cause of saving Humanity, that He humbled Himself to become a man, and to be fully obedient to the law of God, in every respect, as a man, in our place, even to death. He had fulfilled the law for us in full and no longer had any reason to come under law again.