When I’ve taught the Code of Hammurabi, I used it to have my students deduce some aspects of the time, place and culture of Mesopotamia - through their own 21st century lens, mind you, but I figured they should be able to pick out laws that seem logical and even applicable today (there are liability laws that actually make good sense for the time), brutal because of the time period (it’s a fairly violent and merciless code) and ones that apply to their culture from that time period (witchcraft, etc.)
I would not have kids use their creativity to come up with laws to punish slaves, because that doesn’t really serve an educational purpose the way analysis would.
Creativity is something you save for having students design their own coat of arms or something.