You are partially correct. The South seceded legally because it was in their economic best interest to do so. The North invaded to prevent the secession because it was in their best economic interests to do so. Those are the historic facts which have been camouflaged by generations of LEFTIST revisionist historians.
The immorality of slavery is a separate issue which you and I probably agree on.
The legality of what the south did was a matter of speculation and debate long before they launched on that terrible course. And they knew it. They knew it and tabled the debate by force of arms and insurrection.
That insurrection compelled Lincoln to act in accordance with the law and his oath. THOSE are the historic facts which have been camouflaged by generations of LEFTIST revisionist historians.