The moral basis of legality
the purpose of law is to maintain conditions that allow civilizations and societies to exist and function, not to enforce morality.
I agree with the implication that while morality and (ideal) legality overlap, there are things that are illegal but not immoral and things which are immoral but not illegal, and with the substantive point of Marcotte and maha's posts that abortion should be considered both moral and legal. But I think the connection between morality and legality is closer than the standard liberal view lets on.
By maha's standard, I don't see any way to justify a legal rule about abortion -- the topic of the post -- one way or the other without bringing in morality. Neither allowing abortions under all circumstances, nor banning all abortions, nor anything in between strikes me as likely to cause societal collapse. Indeed, we have examples of societies with various policies on abortion, and none of them seem poised to collapse into anarchy or extinction as a result of how accessible abortion is. (It is in one sense unfortunate that societies are capable of continuing to exist indefinitely despite enormous grinding injustices, since that means survival of the fittest hasn't pushed us quicker toward social justice.) So then we have to ask about "functioning." If functioning is to mean anything more than "managing to continue to exist," it requires some sort of ideal of what a well-functioning society looks like. But deciding on any such ideal is necessarily a *moral* question. A society in which abortion is banned is functioning quite well if you think that one of the important things a society should accomplish is to maintain gender roles that subordinate women to men. But it functions quite poorly if you think that what a society is for is to enable its members to pursue happiness on an equal basis. Neither of these ideals is the "real" meaning of social functioning, and it would be a fallacious essentializing reification to claim so. So the only way to choose between them is to make moral arguments, which hold that freedom is a more valuable way of organizing human interactions than adherence to gender roles or vice-versa. (I'm being noncommittal on the substantive questions for the sake of focusing on my argument, but my position is not an inherently relativist one -- I think there are good reasons that freedom really is better, and that enforcement of gender roles is a bad moral position.)
Law and morality are not identical. Many things that are immoral would be too impossible, inefficient, abuse-prone, or unintended-consequence-producing to outlaw. And some things that are moral should nonetheless be illegal because it's necessary, and costs little enough, in order to enable enforcement of illegal-immoral acts. But the law still has an unavoidable moral basis.
(I would speculate that the appeal of the strict separation between morality and legality is a legacy of Christianity. Christianity has traditionally encouraged a view of morality as arbitrary rules. So when some law has a deeper justification -- e.g. "it promotes the pursuit of happiness," as opposed to "because I/God said so!" -- it seems like we're no longer talking about morality.)