As the GOP are so fond of reminding everyone, they are the party of Lincoln. They were federalists and abolitionists. where as the democratic party was states rights, pro-slavery and were constitutional literalness. then 60 years later you have FDR and Henry Wallace being the greatest hope the US ever had at being an equal society. and the republicans being Nixon and Regan and the insanity they are now. so what changed and why?
Your question has been answered in the FAQ: https://www.reddit.com/r/AskHistorians/wiki/us_history#wiki_changing_role_of_republicans_and_democrats.