In the late 1940s, the 'Dixiecrats' adopted the confederate flag as their symbol. The Dixiecrats strongly argued in favor of maintaining Jim Crow laws and racial segregation. Their political movement was founded in response to Truman's directive to desegregate the military.
After the Supreme Court ruled against racial segregation in Brown v. Board of education, the state of Georgia made an alteration to their state flag. The confederate flag was then embedded in Georgia's state flag.
On the 100 year anniversary of the start of the civil war, South Carolina decided to raise the confederate flag in Columbia.
A few years later, Alabama raised the confederate flag over their capital city as well. In this case there was no anniversary of any kind relating to the civil war.
Instead, the flag was raised when Robert Kennedy came to discuss de-segregation with Alabama's governor.
In the heat of the civil rights movement, the confederate flag was used for similar purposes. Particularly during the Selma march, racists waved around the confederate flag to taunt and intimidate the peaceful protesters.
The confederate flag is an inherently racist symbol, after all it was established to represent the side of the civil war that fought specifically to maintain slavery. Hence why you also sometimes see it used for that symbolism in European countries such as Germany and Italy. Over the span of many decades, the confederate flag was linked directly to support for Jim Crow laws and racial segregation. The use the flag for such purposes was not limited to just the former states of the confederacy. Over time, the flag became more prominent amongst Americans living in former Union states with no 'southern heritage' to speak of. The reason for that speaks for itself.
To further emphasize this point, below is an image of Congressman Steve King, representing an Iowa district.
King has repeatedly made racist remarks, often to the point where even top Republicans condemned his remarks.
As you can see, Steve King proudly displays the confederate flag on his desk. King both represents an Iowa district and was born in Iowa, a state that fought
with the Union
against the Confederacy seeking to maintain slavery. Many soldiers from Iowa died in the process. In spite of this, King does not display a Union flag on his desk.
In an unrelated case, the chairman of the Iowa Republican party condemned several officials from his party who chose to display the confederate flag on the 4th of July. In response to Steve King's display, the chairman said he stands by his previous remarks. Iowa's Republican governor likewise disagreed with King's display.
Amongst other things, King has expressed sympathy for the Confederacy. On one such occasion, he said that (black) Americans should be grateful for both sides of the civil war.