I'm not sure I'd put it precisely that way. It's more like if so many people have to die in such a long and drawn out war, then at the very least some good must come out of it. This is not quite the same as saying it was "worth it."
Certainly slavery was a great evil, and it's not at all apparent that it would have ended soon (or even ever) after the 1860s, when the Civil War happened. Even if it did end of its own accord by, say, 1900 (or even 1890, or 1880, or 1870), it's hard to know that the same kinds of guarantees of civil liberties would have (albeit slowly) accrued to the descendants of slaves. Also, an argument is to be made that every day someone is in bondage, that is an injustice of infinite proportions, so that even if slavery would end on its own, it was a moral imperative to end it right away.
Ultimately, of course, I don' t know the answer. All I can really do is just think of what Lincoln said in his second inaugural address:
"Woe unto the world because of offenses; for it must needs be that offenses come, but woe to that man by whom the offense cometh." If we shall suppose that American slavery is one of those offenses which, in the providence of God, must needs come, but which, having continued through His appointed time, He now wills to remove, and that He gives to both North and South this terrible war as the woe due to those by whom the offense came, shall we discern therein any departure from those divine attributes which the believers in a living God always ascribe to Him? Fondly do we hope, fervently do we pray, that this mighty scourge of war may speedily pass away. Yet, if God wills that it continue until all the wealth piled by the bondsman's two hundred and fifty years of unrequited toil shall be sunk, and until every drop of blood drawn with the lash shall be paid by another drawn with the sword, as was said three thousand years ago, so still it must be said "the judgments of the Lord are true and righteous altogether."