Hi, this question would be involved in God plan for eternal salvation being granted to all the holy ones. When Jesus Christ taught that the dead will also be judged, what Jesus actually meant is called the resurrection of the dead and giving them a second chance. But not everyone that died can be resurrected why? Because they do not deserve a second chance. This tells us that both the righteous and the unrighteous will live again, why? Because those that never had a chance to hear the good news preached by Jesus will be given the chance to respond to the message. That does not mean that everyone comes back at one time and the earth is overcrowded, but throughout the millennium so that they can be judged according to actions that they show as clear evidence that salvation is happening to their bodies.
John 5:28-29
Modern English Version (MEV)
28 “Do not marvel at this. For the hour is coming in which all who are in the graves will hear His voice 29 and come out—those who have done good to the resurrection of life, and those who have done evil to the resurrection of judgment.