could you explain why an eighth-month birth is considered a corpse but a seventh-month birth is considered viable?
According to the Gemara, a fully developed baby can be born either in the seventh month or the ninth month. In both cases, the child is fully developed. On the other hand, a child born in the eighth month is a premature child (lacking the development of the ninth month), who cannot survive. [There is however an exception to this rule, since a baby can be fully developed in the seventh month, but nonetheless was born in the eight month.]
In modern times, a baby born in the eighth month can survive and the posskim maintain that he may be treated on Shabbos. According to the Chazon Ish (YD:155), human nature has changed. Rav Shlomo Zalman Aurbach maintained that modern medical equipment (e.g. incubators) enabled the change.
In ancient times there was no chance of survival.