This has been an issue for a long time. But the Bible is really very clear about when a body gets a soul. I did not believe this for years and held on to a number of verses that seem to give basis to argue otherwise. But I am now convinced the Bible is consistent throughout. These slides, Body Gets a Soul, examine this issue carefully.
From the very beginning God stated that He made a body for a man and breathed into that body a breath of life to make man a living soul. There is no reason to believe God does otherwise with bodies that are formed through conception and birth. Every body gets a soul when God breathes into it a breath of life; and that occurs when a baby first breathes. There are verses that state this quite clearly. And verses to which one may appeal in order to argue otherwise are easily explained in light of this truth.
That unborn babies do not yet have souls surely has implications for the acceptability or unacceptability of abortion. What is very evident is that a human body, except for (independent) life itself, fully determines the nature of the soul associated with it. Furthermore, it is God that fully controls the body as it forms. So any attack upon the body as it forms in the womb, is an attack against the purposes of God and against a person to be fully formed in God’s image.
For discussion of these matters see the slides: Body Gets a Soul