Death is in the world among humans because of the sin of our foreparents Adam and Eve:
12 That is why, just as through one man sin entered into the world and death through sin and so death spread to all men because they had all sinned—.
What is sin?
1 John 3:4
4 Everyone who practices sin is also practicing lawlessness, and sin is lawlessness.
And it's not just babies-
23 For all have sinned and fall short of the glory of God,
It is just like a child who inherits a disease from their parents. It is not the child's fault, but he or she suffers. But our Creator through his Son Jesus has provided a way to get out from under the sting of death that is due to sin:
23 For the wages sin pays is death, but the gift God gives is everlasting life+ by Christ Jesus our Lord.
Because of Jesus' sacrifice, both the righteous and the unrighteous in their graves can be resurrected:
John 5:28, 29
28 Do not be amazed at this, for the hour is coming in which all those in the memorial tombs will hear his voice 29 and come out, those who did good things to a resurrection of life, and those who practiced vile things to a resurrection of judgment.
God's justice is fair, because there will be a period in which the resurrected ones cleansed from Adam's sin, will be taught, including babies who die, and those who do not know about God, and those who could not mentally make a decision for or against God's way
Isaiah 26:9, 10
9 In the night I long for you with my whole being,
Yes, my spirit keeps looking for you;
For when there are judgments from you for the earth,
The inhabitants of the land learn about righteousness.
10 Even if the wicked is shown favor,
He will not learn righteousness.
Even in the land of uprightness he will act wickedly,
And he will not see the majesty of Jehovah.
Again, God our Creator is righteous and just, and has given the power of judging to his Son Jesus Christ, and every living human will be able to make a choice based on their faith and their deeds.
13 And the sea gave up the dead in it, and death and the Grave gave up the dead in them, and they were judged individually according to their deeds. 14 And death and the Grave were hurled into the lake of fire. This means the second death, the lake of fire. 15 Furthermore, whoever was not found written in the book of life was hurled into the lake of fire.