It is my understanding that, The Ku Klux Klan was formed after the cινιℓ ωαr, in response to the policies of Radical Republicans, imposed on The South, during the era of post-war "reconstruction." Those policies were based on the idea, which at the time was quite radical, that blacks were completely equal with whites and that southern whites had committed great crimes against humanity, by their enslavement of blacks. Hence, southern whites owed a great debt to blacks, which should immediately be repaid with land, money, weapons, political control and a willingness on the part of southern whites to have their property seized, body beaten or raped and their life taken, if wanted, all in the cause of atoning for their sins against the blacks. I do not think I am exaggerating here.
President Lincoln, while a republican, was a moderate. Hence, he did not wish to punish the south, any further than he felt had been required to bring it into submission to The Union, which the cινιℓ ωαr had accomplished and General Lee had agreed to, when he surrendered. However, their were forces within Lincoln's party that did in fact want to punish the south. They were called the radical republicans and, unfortunately, they dominated reconstruction policies in the south.
In response to the terribly anti-southern-white policies of the radical republicans, during reconstruction, southern whites formed a secret political and military organization to protect whites during reconstruction. After the federal government quit pursuing radical policies in the south, it was, for the most part, disbanded.