his dead body shall not hang on the tree, but certainly you shall bury him on that day, for cursed by God is one that is being hung; so you shall not defile your land that Yahweh your God is giving to you as an inheritance.”” (Deuteronomy 21:23, LEB)

It’s difficult to imagine the horror with which the Jews looked on anyone who was hung on a tree.  If one was hung then ipso facto that person was cursed by God.

Paul will refer to this verse when he explains the shame of the cross:

Christ redeemed us from the curse of the law by becoming a curse for us—for it is written, “Cursed is everyone who is hanged on a tree”—” (Galatians 3:13, ESV)

We deserved to be cursed by the law because we are serial law-breakers.  This is the bad news, none of us can escape the sentence of just punishment.  The good news is that Jesus took our curse upon himself at the cross.  He was cursed, we were declared law-keepers.  Amazing love!

The Zondervan NIV Study Bible makes an interesting point:

This law combined with the previous two laws, the inheritance of the firstborn son (vv. 15-17) and the stubborn and rebellious son who is executed (vv. 18-21), certainly played a role in the apostle Paul’s thought. His reflection on the disobedience of Israel as God’s firstborn son and the execution of Jesus, the obedient son, on a tree connects the theological “dots” in these laws (Gal 3:10-13). Christ accepts the curse for a lost and rebellious humanity.