Question: "Can a child who is conceived out of wedlock be saved?"
Answer: In Deuteronomy 23:2, the Mosaic Law says, "The child begotten out of wedlock or incest shall not enter into the congregation of the Lord; even to his tenth generation shall he not enter into the congregation of the Lord." What this was saying is the child born out of wedlock was illegitimate and unworthy of Israelite citizenship for ten generations. This does not mean, as some mistakenly think, that an illegitimate person cannot be saved or be used greatly by God. His mercy and grace through Christ are sufficient for all.
In the New Testament, Hebrews 12:8 mentions "But if you are without correction, where all are partakers, then are you bastards, and not sons." This is telling us that whom the Lord loves He chastens, and corrects every child of His. Those He does not correct and discipline are not really His children, and therefore, will not enter the Kingdom of Heaven. We must be one of God's own, born from above, to enter into Heaven.
So we can clearly see that anyone who trusts Jesus Christ as his or her personal Savior will enter the Kingdom of Heaven. John 3:16-18 says it all, "For God so loved the world, that He gave His only begotten Son, that whosoever believes in Him should not perish, but have everlasting life. For God sent not his Son into the world to condemn the world, but that the world through Him might be saved. He that believes on him is not condemned; but he that believes not is condemned already, because he has not believed in the name of the only begotten Son of God."
When God looks down on His children who have received that free gift of salvation through the death, burial, and resurrection of Jesus Christ, He does not see our nationality, color, legitimacy or non-legitimacy of birth, only the righteousness of Christ in us (2 Corinthians 5:21; Philippians 3:9). We are not saved because of who we are from birth; rather, we are saved because of who we become at the new birth. We become new creations in Christ. “Therefore, if anyone is in Christ, he is a new creation; old things have passed away; behold, all things have become new” (2 Corinthians 5:17). When a child born out of wedlock is born again, he/she becomes a son or daughter of the living God (John 1:12).
In Psalm 139 David is praising God for "You shaped me first inside, then out; You formed me in my mother's womb. I thank you, High God - you're breathtaking! Body and soul, I am marvelously made! I worship in adoration - what a creation! You know me inside and out, you know every bone in my body; You know exactly how I was made, bit by bit, how I was sculpted from nothing into something. Like an open book, you watched me grow from conception to birth; all the stages of my life were spread out before you. The days of my life all prepared before I'd even lived one day. Your thoughts - how rare, how beautiful! God, I'll never comprehend them!"
Our marvelous Creator loves all the little fetuses, no matter the state of conception, and has through His grace, provided a home in heaven for all who will receive that free gift of salvation. Praise the Lord!