His agony and his death on the cross were necessary to redirect the full wrath of God away from the whole of mankind who deserve to be thrown into hell for our sins.
Think of it like this:
You are a criminal condemned to die by lethal injection at 3:10 am. At 3:08, they are strapping you onto the table and prepping the equipment. You are unequivocally guilty of comitting the horrible crimes with which you have been charged and yet you don't want to die. In your own mind, you don't deserve to die. At 3:09, there is a commotion in the execution chamber ....
... as someone struggles to get past prison personnel into the room. At this point, they have you strapped in and are ready to begin the execution. After some commotion, you feel the straps being unfastened. Why has this person disrupted your execution? You have no idea. Strong hands yank you off the gurney. In amazement, you watch as the unknown person wordlessly convinces the doctors and guards to strap him down in your place. You have no idea who he is, why he's here, or why any of this is happening. As the needle goes into his arm, he looks at you and smiles.