God's judgment of death was not a punishment. It was a consequence of Adam's sinful behavior.
"By the sweat of your face You will eat bread, Till you return to the ground, Because
from it you were taken; For you are dust, And to dust you shall return.'" (Gen 3:19)