There are definitely a few answers about this in the /r/AskHistorians FAQ - it's amongst our most common questions! /u/Samuel_Gompers did a fine job answering both of these old questions:
Let me step back real quick and offer a note about party ideology. Very generally Democrats (prior to the modern era) were seen as supporting the rural agrarian, the farmer and so on. So, that's why there WERE so many of them in the South and that's why they were the more overtly racist party up until recently. The GOP were supposed to represent the business class, and so they were popular in states with a lot of cities and manufacturing.
But while the parties have shifted their ideology over the past few decades, the people they support haven't really changed. In other words, a Southern Republican today (especially a white male one) would have probably been a Democrat in 1960.
However, his worldview need not have changed.
But the shift in ideologies happened for couple of reasons. First, the biggest shift happened after the Civil Rights Act passed. The Democrats were then associated with passing laws that benefited black people. In the South, Democrats controlled politics.
However, the VRA was very unpopular and so politicians who wanted to win elections had to do something to distance themselves from it. In 1968, Nixon ran for president using dog whistle tactics to lure white racist (but Democratic) voters to vote him into office. Indeed, his administration was not progressive on the race issue and so that opened the doors for a lot of other racist (or calculating) would-be politicians who wanted to get into office.
Meanwhile, Bobby Kennedy, in his race in '68, he openly embraced progressive values and equal rights and so on.
Since then, the Democrats have been seen as more inclusive and tolerant generally.
Another big shift was in the late 1980s on the climate. Nixon signed the law authorizing the EPA and both Reagan and George HW Bush took the ozone hole threat seriously. However, after President Clinton and Al Gore made the environment as one of their big "pet" issues, Republicans figured they couldn't (or didn't want to) compete. George W. Bush ran for office in 2000 and, as he was from Texas, oil country, he couldn't reasonably talk about solar power and renewable energy because a lot of his base came from that sector and from then on, the GOP has kind of backed away from environmental issues because they could never be liberal enough to win elections by trying to get the support of the people who are motivated to vote based on environmental concerns. The GOP has always been the party of the businessman, and a lot of those businesses are hurting the environment.
In addition to THAT, the right saw they could use the environment to divide and actually hurt the Democrats. In 1994 President Clinton signed the Northwest Forest Plan to protest the Spotted Owl. The owls had already been unpopular in the region because logging groups claimed that owl protection would mean jobs, but Clinton, a Democrat, specifically sought to protect a very unpopular animal among working class men in the rural Northwest area. So, right wing radio (Rush Limbaugh) pounced on this as evidence that bleeding heart liberals would rather protect birds than people and that's basically been the message since then. But yeah, George H. W. Bush actually went to Rio and participated in the first big multi-state summit on the climate. We've come a long way since then.
I can offer more details if you like.
Source: Terminal degree in Southern history and I lived through the '90s and remember well the stupid right wing talking points about the owls.
EDIT: Changed ERA to EPA. sorry.