Former Confederate General John B. Gordon testified in 1871 to the Joint Congressional Committee on Affairs in the Insurrectionary States that: "The first and main reason (for the Klan) was the organization of the Union League."
There you have the stated purpose, at least by Gen. Gordon, for the formation of the KKK. Here is the stated purpose for the formation of the Union League.
Excerpt: "The first Union League formed in Ohio in 1862, when Confederate military successes coupled with political unrest in the North caused many to doubt a Union victory in the war. The Ohio Union League thrived and soon similar leagues spread to more than eighteen northern states. According to historian Clement M. Silvestro, Union Leagues proposed "to combat and crush the Knights of the Golden Circle, Sons of Liberty, The Order of American Knights, and similar clubs associated with the Democratic Party.""