"'For now I would be lying down in peace; I would be asleep and at rest with kings and rulers of the earth, who built for themselves places now lying in ruins, with princes who had gold, who filled their houses with silver.'" NIV translation
Job continues as he compares the rest in the grave as a dead child to the doom and gloom that he is now facing. He is right in the fact that, if he had died during childbirth, he would have gone to sleep and waited for the Lord. After Jesus died on the cross and was raised from the dead, he would have rose with Christ and gone to heaven. Even so, he is missing the fact that God is in control of all things and has a purpose for all of us. He has lost sight of the fact that God knows all things and desires what is best for us.
"'Or why was I not hidden away in the ground like a stillborn child, like an infant who never saw the light of day? There the wicked cease from turmoil, and there the weary are at rest. Captives also enjoy their ease; they no longer hear the slave driver's shout. The small and the great are there, and the slaves are freed from their owners.'" NIV translation
Job continues to sink further into depression as he wonders why he did not die at the moment of birth. An infant would have the same fate as the child that was not carried to term as they would now be in heaven with Jesus but the "wicked" are not.
Here, we see a misunderstanding that Job had which many people of today also share. That is the thinking that the "wicked" (those that do not know the Lord) are resting in the grave. Although it is true that they are in the grave, it is not a time of rest as they can only look forward to the time where they will be judged and sentenced to hell. While men are yet alive, they can deny the existence of God and deny His Son but, upon death, they find out that they were very wrong.