Why have the Democratic Party and Republican Party switched positions on civil rights since the Civil War?
Did the parties switch? As a first step in answering the question, consider the assumptions implicit in it and other potential explanations. So let's assume that the parties did not switch. What else could explain the current positions?
Republicans were against racial preferences in 1860 and are still against them in 2016. Democrats were for racial preferences in 1860 and are for them again in 2016. Admittedly the Democrats' position has changed. In 1860, they advocated racial preferences favoring whites, and in 2016, they advocate racial preferences favoring blacks. And of course, slavery and affirmative action are not the same.
From that perspective, what changed is the goal. Prior to the 1960s explicit policies were limiting blacks. Since then only implicit policies and historical disadvantage have been limiting blacks. So prior to the 1960s, blacks and Republicans were in favor of getting rid of negative laws. Since the 1960s, blacks and Democrats were in favor of establishing active laws.
If you view laws as either pro-black or anti-black (or pro-white or anti-white), then the parties switched positions. If you view laws as either favoring preferential treatment or opposing preferential treatment, then the parties have moved in such a way as to get back to their original positions. Republicans oppose active racial preferences while accepting differing outcomes. Democrats reject differing outcomes for groups to the point of favoring affirmative action to address them.
Rather obviously, affirmative action has a stronger moral basis than Jim Crow laws. Its goal is to move towards balanced outcomes while Jim Crow laws were intended to preserve unbalanced outcomes. But good intentions are no guarantee of good outcomes.
The worst part of the current partisan split is that both sides can argue that they have a moral basis for their position. So each can accuse the other of ignoring the moral basis of its side. And both be right.
Voters changed parties
There were two big shifts from Democrats to Republicans in black voting. One happened around 1932, as blacks overwhelmingly rejected Hoover and embraced Roosevelt. The second happened around 1964. Reasons aren't entirely clear. Johnson had notable anti-poverty programs, civil rights bills, and lingering goodwill from the Kennedy assassination.
The noteworthy part though is that these shifts persisted. As a result, there was much more support in the party for black objectives. This came to a head in 1968, when many Southern whites stopped voting for the Democratic presidential candidate. This led to Republicans winning five of the next six presidential elections.
Then in 1994, legislative positions followed. Lifelong white Democrats who had been splitting their tickets between local Democrats and national Republicans, voted for local Republicans. Ticket splitting dropped to its lowest levels in decades. In 2006 and 2008, this ebbed a bit, but then it returned in 2010 and 2014.
Note Figure 2.