Rational people don’t think that some magical process occurs between one instant and the next as a fetus goes from “ok to abort legally” to “illegal to abort.” The law also isn’t as involved in the spiritual or emotional content of the debate, but the practical implications. As such, law represents a compromise, hopefully a reasonable one.
Part of the problem is that some people look at a fetus and think, “small baby” and others see a potential baby. For some there is a moral imperative to support that potential, and for others there isn’t. Yet others look at a newborn and see a person, others see a potential person. The problem is that this debate is ultimately too emotionally charged for the hard biological reality to enter for most.
As a result, the law picks viability of the fetus as a line, not because of some magical transformation, but for practical reasons. It does this because outlawing abortion in no way stops abortion, it just drives it underground. The law also recognizes that the mother is a fully viable and developed person with their own rights, and (this is going to sound harsh) playing host to a parasitic organism.
Needless to say none of what I’m saying goes over well with people who don’t have a strong background in biology. The idea that the life of the mother might matter more than the life of another potential person doesn’t sit well with some people. The idea that even newborns are less “people” and and more “grub-stage people” tends to be downright offensive to many.