How come the Democratic Party switched to the party of the poor and the Republican party switched to the party of the rich?
While ever since the days of WJ Bryan you could, with too much simplification, claim that the Democrats are the party of the poor, there never was a time when it could be claimed that the Republican party was the party of the poor.
The Homestead Act gave land to the landless, the Morrill Act provided for the creation and support of agricultural and technical schools that taught practical subjects for the benefit of the masses, and a number of other progessive measures that the Repubicans were able to enact in the 1860's once the southern conservative Democrats were gone from Congress after secession.
In the 1860's and 1870's the Republicans were the party of economic intervention by government and the Democrats were not. This divison wasn't based on class lines, and if the tilt into class based politics had happened then instead of later, by which time the intervention the Republicans favored was done largely only on behalf of business, I can easily see the Republicans becoming the leftist party and the Democrats the rightist party.