There is general agreement that a widow must wait a period of time after the death of her husband before re-marrying, to ensure that should she see signs of pregnancy soon after the death of her first husband, the paternity of the child will not be in doubt. The Talmud assumes that all pregnancies become obvious within three months of conception, and so a woman can remarry after she waits three months from the death of her first husband. Shmuel explains the importance of uncontested paternity:
’משום דאמר קרא: ’להיות לך לאלקים ולזרעך אחריך
להבחין בין זרעו של ראשון לזרעו של שני
So far so good. But then the Talmud analyses the viability of a child born prematurely in which the father may be either the first husband who subsequently died, or a second man, to whom the mother re-married very son after the death of her first husband. The Talmud suggests that the women need wait two and a half months after the death of her first husband. If a child is born seven months later, it must have been fathered by the second husband, since (i) if it was fathered by the first husband the gestational period would be nine and a half months, which is assumed to be impossible, and (ii) if it was fathered by the first husband but was born prematurely, the gestational period would have to have been eight months - and as Rashi explains - an eight month fetus is not viable. This belief - that a fetus of seven months gestation may survive, but one born in the eighth month of gestation cannot do so - is very odd. But it wasn't a uniquely Jewish belief.
Homer's Iliad, written around the 8th century BCE, records that a seven month fetus could survive. But it is not until Hippocrates (c. 460-370 BCE, or some 500 years before Shmuel), that we find a record of the belief that a fetus of eight months' gestation cannot survive, while a seventh month fetus (and certainly one of nine month gestation) can. His Peri Eptamenou (On the Seventh Month Embryo) and Peri Oktamenou (On the Eight-Month Embryo) date from the end of the fifth century BCE, but this belief is viewed with skepticism by Aristotle.
In Egypt, and in some other places where the women are fruitful and are wont to bear and bring forth many children without difficulty, and where the children when born are capable of living even if they be born subject to deformity, in these places the eight-months' children live and are brought up, but in Greece it is only a few of them that survive while most perish. And this being the general experience, when such a child does happen to survive the mother is apt to think that it was not an eight months' child after all, but that she had conceived at an earlier period without being aware of it.
The belief that an eight month fetus cannot survive has a halakhic reification: Maimonides ruled that if a boy was born prematurely in the eighth month of his gestation and the day of his circumcision (8 days after his birth) fell out on shabbat, the circumcision - which otherwise would indeed occur on shabbat, is postponed until Sunday, the ninth day after his birth.
ומי שנולד בחדש השמיני לעבורו קודם שתגמר ברייתו שהוא כנפל מפני שאינו חי... אין דוחין השבת אלא נימולין באחד בשבת שהוא יום תשיעי שלהן
(הלכות מילה 1:11)
This belief persisted well into the early modern era. Here is a state of the art medical text published in 1636 by John Sadler. Read what he has to say on the reasons that an eight month fetus cannot survive (and note the name of the publisher at the bottom of the title page-surely somewhat of a rarity then) :
Saturn predominates in the eighth month of pregnancy, and since that planet is "cold and dry"," it destroys the nature of the childe". That, or some odd yearning of the child to be born in the seventh but not the eight month (according to Hippocrates) is the reason that a child born at seven and nine months' gestation may survive, but not one born at after only eight months.
Today, gestational length is of course critical, and, all things being equal, the closer the gestational length is to full term, the greater the likelihood of survival. We can say with great certainty, that an infant born at 32 weeks or later (that's about eight months) is in fact more likely to survive than one born at 28 weeks (a seven month gestation.) In fact, a seven month fetus has a survival rate of 38-90% (depending on its birthweight), while an eight month fetus has a survival rate of 50-98%. Here is the data, taken from a British study.
More recently, a study from the Technion in Haifa showed that even the last six weeks of pregnancy play a critical role in the development of the fetus. This study found a threefold increase in the infant death rate in those born between 34 and 37 weeks when compared full term babies.
You can read more on the history of the eight month fetus in a 1988 paper by Rosemary Reiss and Avner Ash. From what we have reviewed, the talmudic belief in the unusually low survival rate of an eight month fetus (compared to a seven month one) is one that was widely shared in the ancient world. And one that is not supported by any of the evidence we now have.