The Adventures of Huckleberry Finn was published in 1884, less than twenty years after the end of the Civil War. In the years immediately after the end of the war, known as the Reconstruction period (1865-1876), the southern states were brought back into the Union with many changes in their circumstances. Laws were passed allowing newly freed former slaves to vote, to acquire property and own businesses, to attend desegregated schools, and to assume the rights of all citizens.
A backlash against all these changes developed among whites whose authority and position was being threatened by the changes enacted during Reconstruction. Groups such as the Ku Klux Klan formed to terrorize blacks and proclaim white supremacy, Jim Crow laws were passed in southern states to reestablish segregation, and many of the advances in equal status for blacks were lost during the 1880s and 1890s.
Huck lived in a time period before the Civil War, but Twain did not. He used Huck's evolving opinions and actions to vividly express his own thoughts and opinions about the institution of slavery, the morality of discrimination, and the rights of all people.