At the cross, God was punishing Jesus for the sins of the world. God's justice required a penalty from sinners, and in his unspeakable love, he paid the penalty himself in the person of his crucified Son.