The claim that they fought to free the black man arose during the war (about half way through it) so that the Northerners wouldn't feel so bad about invading and murdering people who had done them no harm, and who only wanted to be left alone.
Also to assuage their consciences and expand their political power ever since. It's a lot easier to feel good about destroying people's lives if you portray them as evil. It's an old technique that still works today.
Hitler did it too.
Again I never contended that the North was fighting to free blacks in 1861. However, the South was fighting to keep them enslaved.