Positive commandment · Mitzvat Aseh #230 of 613
To hang [the corpses] of those liable for hanging
לתלות מי שנתחייב תלייה
The verse · Devarim 21:22
וְכִי־יִהְיֶה בְאִישׁ חֵטְא מִשְׁפַּט־מָוֶת וְהוּמָת וְתָלִיתָ אֹתוֹ עַל־עֵץ
“And if a man have committed a sin worthy of death, and he is put to death, and thou hang him on a tree:”
The Rambam’s words
To hang [the corpses] of those liable for hanging, as [Deuteronomy 21:22] states: "And you shall hang them on a gallows."
לתלות מי שנתחייב תלייה, שנאמר: "ותלית אותו, על עץ" (דברים כא,כב).
Why · Sefer HaChinuch #535
To hang one who is liable for hanging
“The root of this commandment is revealed to all, as “by justice a king sustains the land.” As were it not for the fear of judgment, people would kill one another.”
Who & when
“This commandment is practiced during the time of the Temple, when we had the power in our hands to judge capital punishments; and specifically by males, as it is up to them to establish justice.”
Where in the Mishneh Torah
Hilchot The Sanhedrin and the Penalties within Their Jurisdiction הלכות סנהדרין והעונשין המסורין להם