The basic text here is John 3:5 "Very truly, I tell you, no one can enter the kingdom of God without being born of water and Spirit." which was taken to mean that the unbaptized cannot be saved. Theologians then asked, "What about small babies who die before they can be baptized? Are they going to hell? Is this fair?". To answer this, they invented limbus puerorum -- "limbo of the children" -- essentially out of thin air.

Nowadays, the attitude is "Of course a loving and merciful God would not have that happen", and limbo has fallen into disrepair.