Death is a part of human life.
But death only affects the mortal body.
The spirit is not affected.
When a man dies, his spirit lives although his body dies.
God is Spirit.
In order for God to die, He prepared for Himself a mortal body.
He permitted the body to die, but He continued to live, because spirits don’t die.
Why did God die? In order to bring about the salvation of the world.
Hebrews 9:15 And for this cause he is the mediator of the new testament, that by means of death, for the redemption of the transgressions that were under the first testament, they which are called might receive the promise of eternal inheritance. 16 For where a testament is, there must also of necessity be the death of the testator. 17 For a testament is of force after men are dead: otherwise it is of no strength at all while the testator liveth.