"If a man has committed a sin deserving of death, and he is put to death, and you hang him on a tree, his body shall not remain overnight on the tree, but you shall surely bury him that day, so that you do not defile the land which the LORD your God is giving you as an inheritance; for he who is hanged is accursed of God.” (vv.22-23)
Deuteronomy 21 lays out various laws; The law of unsolved murders (vv.1-9), Laws regarding the taking of a wife from conquered peoples (vv.10-14), Laws regarding the protection of inheritance rights (vv.15-16), The penalty for a rebellious son (vv.18-21), and the law if a man has committed a sin deserving of death (vv.22-23). Our text is very clear here that such a man, if you hang him on a tree, his body shall not remain on the tree overnight.
In the thinking of ancient Israel there was something worse than being put to death, having your corpse left exposed to shame, humiliation, and scavenging animals and birds. Hang him on a tree does not have the idea of being executed by strangulation; but of having the corpse mounted on a tree or other prominent place, to expose the executed one to disgrace and the elements.
However God's grace dictated that, His body shall not remain overnight on the tree, but you shall surely bury him that day: Therefore, if anyone was executed and deemed worthy of such disgrace (and you hang him on a tree), the humiliation to his memory and his family must not be excessive. This was a way of tempering even the most severe judgment with mercy.
The punishment of being hanged on a tree, and left to open exposure, was thought to be so severe, that it was reserved only for those for which is was to be declared: “this one is accursed of God.” Paul expounds on Deuteronomy 21:23 in Galatians 3:13-14: Christ has redeemed us from the curse of the law, having become a curse for us (for it is written, “Cursed is everyone who hangs on a tree”), that the blessing of Abraham might come upon the Gentiles in Christ Jesus, that we might receive the promise of the Spirit through faith. Jesus not only died in our place; but He also took the place as the accursed of God, being hung on a “tree” in open shame and degradation. He received this curse, which we deserved, and He did not, so that we could receive the blessing of Abraham, which He deserved, and we did not.
Therefore, we are redeemed from the curse of the law by the work of Jesus on the cross for us. We no longer have to fear that God wants to curse us; He wants to bless us, not because of who we are, or what we have done, but because of what Jesus Christ has done on our behalf.
The Truth: "For God made Him who knew no sin to be sin for us, that we might become the righteousness of God in Christ Jesus." (2 Corinthians 5:21)