This is a question that Christians often ask but few answer from the Scriptures. I found this article by Matt Privett to be very helpful. Here's the conclusion to his essay:
With the evidence pointing toward the idea that all infants and unborn who die are excluded from judgment and included in heaven, the method of their inclusion remains at issue. The Bible indicates that no man is saved by the works that he does, but by grace alone (Rom 3:20; Eph 2:8-9). It is by grace that God has saved sinners throughout all of human history, not just in the New Testament (Gen 15:6). Scripture is explicit that there is no other way to come into God’s favor (Rom 3:21-26). In addition, there is no place in God’s Word that teaches the damnation of infants and unborn. On the contrary, every biblical reference to the issue, whether explicit or implicit, gives reason to believe they go directly into the presence of God when they physically die.
That being the case, infants are saved by the grace of God through the finished, redemptive work of Jesus Christ the way every other human inhabitant of heaven is. All babies are in need of a Savior because of the guilt of Adam; however, they are innocent of personal sinful deeds, rebellious acts, and unbelief.25 These individuals do not reach the state where they comprehend revelation and have the ability to choose or reject the gospel. Thus, they are not condemned and God has provided them the one and only Savior. As a result, one is left to conclude that all infants, unborn, and mentally incapable who die before reaching a state of accountability are among the elect, whom God graciously receives into His glorious presence at the moment of physical death (2 Tim 2:10).
Just as David’s dead infant son went to a place where he would one day be joined by his earthly father (2 Sam 12:23), all infants who die in that state go to heaven. Just as Jeremiah was known by God, consecrated from his mother’s womb, and appointed a prophet to the nations (Jer 1:5), all babies who die are known by God and ultimately glorified with Him (Rom 8:30). Just as John the Baptist was full of the Holy Spirit while still inside the body of Elizabeth, all of the unborn who die are washed from their inherited sinful state by the regenerating and renewing of the Holy Spirit (Tit 3:5). Thus, when asked what the eternal destiny of one of these who die is, one can answer with biblical confidence as MacArthur does, “Instant heaven.”
Read "Why we believe children who die go to heaven?" by Al Mohler and Danny Akin