Until modern times, when science has demonstrated the way a child is formed in the womb, there were many debates as to when a foetus was said to be ensouled. Since the classical understanding of the soul is that it is an animating principle, the general answer was that a foetus was said to be ensouled when it was formed in a way that it resembled the human form and that it was moving in the womb. Until that point, which was generally assumed to happen around forty days after conception, the flesh was believed to be taken up by the woman’s body and formed so as to receive the soul sent to it by God. Questions about abortion, such as whether or not aborted foetuses would be brought back to life at the resurrection of the dead, were answered according to this assumption. If there were no life, no soul, there is nothing to raise; but once the soul was in place, the child would be raised from the dead, like everyone else. Let us look at this typical presentation of the matter:
From: Peter Lombard, The Sentences: Book 4. trans. Giulio Silano (Toronto: Pontifical Institute of Medieval Studies, 2010), 243-4( Dist. XLIV, c.8).
ON ABORTED FOETUSES AND MONSTERS. It is also necessary to inquire whether aborted foetuses and monsters will rise again, and what they will be like.
AUGUSTINE, IN THE ENCHIRIDION: Regarding this, Augustine speaks as follows: “A question arises about aborted foetuses, which have already been born in their mother’s wombs, but not in such a way that they can now be born again. For if we should say that these are to rise again, what we say can be accepted as to those which are already formed. But who is not more disposed to think that they unformed ones perish, like seeds that were not conceived?” — PAY ATTENTION! “It may be very carefully asked and disputed by learned men, when a human person begins to live in the womb and whether life exists in a hidden way which is not yet manifest from the movements of a living being. It seems too exceedingly shameless to deny that those pregnancies had been alive which were cut out limb by limb, lest, if they were left dead in the wombs, the mothers should die too. From the time then that a person begins to live, from that same time he is already able to die. And if he is dead, wherever death may come upon him, I cannot discover how he can be denied a part in the resurrection.”
HERE ON MONSTERS “Now shall we deny that monsters, which are born alive, however quickly they may die, will rise again, and we must believe that they will not rise again in their deformity, but rather with a corrected and perfected nature. (ON CONJOINED TWINS.) A man with two sets of limbs was recently born in the East, of whom an account was brought by most faithful brethren who had seen him, — an account which Saint Jerome left in writing. Far be it from us to think that one man with two sets of limbs shall rise again, and not two distinct men, as would have happened, if twins had been born. So also other births, which, because of their great deformity, are called monsters, shall at the resurrection be restored to the normal human form.” 
There are many interesting things in this text, though we will only look at a couple of them.
First, we see that St. Augustine’s opinions were used to generate the normative medieval answer to this question. St. Augustine suggests that, until the time, of ensoulment, the embryo is not alive and therefore will not have a share in the resurrection. His idea should make modern Catholics uncomfortable. It is because, unlike what many think, this uncertainty remains an acceptable position (with many caveats, to be sure). If some of the greatest Catholic minds can be uncertain as to when human life begins, we should not be surprised that others, who are far less holy, far less educated in matters of faith, will also not know what to think of this matter. We are often quick to judge them for their ignorance – yet, in an empirical age such as ours, we should not be surprised that metaphysical questions remain ineffable for the ordinary person. This also points out that, until recent times, the Church’s answer to this question was one of uncertainty, and so we should treat others with charity if they remain uncertain. Indeed, it is quite clear, this tradition influences many people within the Church today. We should at least recognize that they struggle with a question which has been raised since before the advent of Christ, and treat them with charity rather than contempt. Now, to be sure, if one understood the principle of the soul as being the animating force of the person, then when we see self-movement (such as cellular growth and division), it makes sense to believe that the person is alive. But then one could question whether or not the soul of the human evolves as the embryo develops, so that, just as in evolution, so in the womb, we see a creature slowly developing into a human and becoming human at some point when God grants the soul human rationality. I do not find this argument persuasive, because I believe that this is too dualist an approach between body and soul, but it is a metaphysical question which appears to allow different answers depending upon philosophical presuppositions, and we should consider this the modern equivalent of the Augustinian uncertainty. Bringing up the immaculate conception also does not reveal an answer to this question: the immaculate conception tells us about Mary’s purity, which is tied to her conception, but it does not tell us when the human soul of Mary was placed into the embryo; tradition has long understood that the flesh of Mary was special, was itself cleansed from all impurity, and this could have been done with or without the soul dwelling in the flesh. Of course, I do not believe this is the case, because, again, this requires a dualistic understanding of body and soul, one which believes them to be imperfectly joined together instead of forming one essential unity.Secondly, there is a vague discussion about abortion, about cutting up the foetus limb from limb, for the sake of the mother’s health. There are two ways one could read this text. The first, and most orthodox, would be to say this is about a child which lived and died in the womb: it needed to be taken out lest it caused the woman’s death. However, this is not exactly clear. One could read it as indicating that abortion could have been done for the sake of the mother’s health, and that the child itself was required to be taken out for the sake her life. The method for this would have been brutal, because of the limited medical technology of the time. In either case, Augustine is clear that we are talking about a child which has received its soul, and he says these children will indeed be raised in the eschaton. If one reads it as a discussion of abortion done for the sake of the mother’s health, this does not mean, however, it is approved, nor does it indicate what exactly Augustine thought should be done for those who practice such abortions. His interest lay in the fact that such foetuses will partake of the resurrection, and will be properly formed in the eschaton. Deformity, whether in the womb, or outside, when it leads to death will be something which is healed in the resurrection. Deformity is an accidental, secondary quality. Depending upon the nature of the deformity, of course, the way it is healed will differ: thus, conjoined twins do not have to be seen as conjoined in eternity, though of course, one could suggest their physical union leads to an intimate spiritual communion, and this spiritual communion will remain.
The point of this exploration is to admit that there are difficult questions when it comes to life, and when human life begins, and how we are to understand the human person. What exactly is human life? When does it begin? What qualities of the human person, as they exist in history, will be found in eternity? Even if one has good reasons for their own answers to these questions, that some of the greatest minds of the Church recognized them as important and worthy of consideration via scholastic inquiry, should again allow us to deal with the issue the same way. This is not to say we need to ignore our views of life. Even if one were to come to accept a late ensoulment, this does not mean one can therefore approve of abortion: indeed, even when the majority of the Church considered it probable that the soul was given to the foetus weeks after conception, they did not approve of abortion. We must therefore not entirely confuse the two issues. Though they are related, if we base our argument on the time of ensoulment, in a world where there is no belief in souls, such arguments will fail. Rather, we must look back to the tradition and see why abortion, even if there was no soul in the child, was rejected. We must remember how the Church is to go to people where they are at, with their own presuppositions; focusing on when a child is ensouled requires presupposition which many in an empically-minded world do not believe.