This question is one close to our hearts. As the Bible does not spell out the answer in any particular manner, I will render my opinion based on the “big picture” of God’s revelation.
First, we understand that no circumstance is unused by God; He “works all things according to the counsel of His will” (Ephesians 1:11, ESV). Therefore, we trust that even the tragedy of the death of King David’s little child had many purposes. One reason, I believe, is for countless people to glean hope regarding the death of children. After praying and fasting that His child not die, David arose and ate upon hearing of the death of his son. When criticized by his servants for rising and eating, David explained, “While the child was alive, I fasted and wept, for I said, ‘Who knows whether the LORD will be gracious to me, that the child may live?’ But now he is dead. Why should I fast? Can I bring him back again? I shall go to him, but he will not return to me.” (II Samuel 12:22-23, ESV, emphasis mine)
King David certainly knew the depths of God’s mercy and salvation. The Holy Spirit has chosen to reveal through the situation the fact that David believed he would one day go to his child. The man of God was obviously convinced that he would be reunited with his son in an actual way. In David’s heart, there existed a comfort in knowing the reality of a place called Heaven and his child’s location and safety there.
Second, in the New Testament we catch the heartbeat of Jesus when children were brought to Him to be prayed for and to have the Son of God lay hands on them. The disciples rebuked people for bothering Jesus with children, but our Lord proclaimed, “Let the little children come to me and do not hinder them, for to such belongs the kingdom of heaven.” (Matthew 19:14, ESV)
The Greek word for “children” here includes little ones and infants. Jesus made one thing abundantly clear to both his disciples and the broader public – God wants children coming to Him! He even speaks metaphorically of the need for people of all ages to trust and be vulnerable as children, for this represents the heart of those who enter the Kingdom of Heaven. In terms of the issue at hand, we see – most importantly – that Jesus is very much for children coming to Him and against their being held back from His presence.
Third, Romans 1:18-20 concisely explains that people are without excuse before God because they knowingly suppress the truth that is before them and refuse to acknowledge the existence of a Creator to whom we are accountable, in light of the evidence of the created universe. How could infants and small children possibly apprehend the truth revealed in creation and the attributes of God made evident by what He has designed? How could babies suppress truth? We logically begin to see that small children could not fit into the category of those “without excuse.” For that matter, nor could the severely mentally challenged people of the world. And although God does not go on to explicitly outline a sub-category for infants and those without sufficient mental capacity, we catch glimpses of His heart elsewhere.
For the three main reasons outlined above, I believe we will be joyfully reunited in Heaven with the people we have known here on earth for such a short period of time because of their death in infancy or childhood. Ultimately, we stand on the words of Abraham in Genesis 18:25 (NIV, 1984), “Will not the Judge of all the earth do right?”