Deuteronomy 21:22 "And you shall hang him on a tree"

Some sins are so serious that the court is commanded to publicly hang the corpses of the transgressors.

The hanging takes place only after the person is put to death by the Beit Din. People will then see the severe consequences of violating HaShem's will.