Really? It is my impression that it is very much the other way around. The propaganda/fiction that the Union invaded the South to stop slavery has been repeated so often that now most people believe it.
The truth is more mundane and less noble. They invaded the South to stop Independence, not slavery.
But wasn’t the reason the south seceded was due to many northern states not wanting slavery and northern states invoking their states rights to do it and the feds deciding not to enforce their statute against the north. Once the south states left the feds had no choice but to stop it.