Not sure if this question is more about history or politics, but if this is the right sub:
How and when did this shift happen where the Republican party became associated with the conservative racists and the Democrats the social progressives compared to the reverse during the Civil War?
The tl;dr is that the American political parties switched sides in the mid- to late-20th century. Plenty more about this in our FAQ.