Think it's strange that the now-lily-white Republican Party was the choice of freed slaves in the 19th century?
It's simple, really: It was a very different Republican Party. The then-pro-slavery and segregationist Democratic Party (then called "Dixiecrats" in the South) basically switched parties with Republicans in the 1960s after conservative Barry Goldwater led the national Republican Party away from supporting issues considered friendly to African Americans, attracting former white Democrats who were disenchanted with their national party's support of the Civil Rights Act of 1964.
As then-President Lyndon Johnson, a Democrat, put down his pen after signing the legislation, he turned to his two aides, Bill Moyers and Jack Valenti, and said, "We have lost the South for a generation."
In essence, the Party of Lincoln became the Party of Strom. (Strom Thurmond was the segregationist leader of the Dixiecrats.)
To his credit, President Johnson signed the act anyway, making segregation and Jim Crow laws unconstitutional in schools, the workplace and facilities that serve the public, and prohibiting unfair and unequal voter-registration requirements used to keep African Americans from voting.
In the years following, first Richard Nixon and then Ronald Reagan employed what is now known as the "southern strategy" to get white southerners to vote for Republicans based on not-so-veiled racism such as (inaccurate) rhetoric about "welfare mothers" and Willie Horton. Political strategists Haley Barbour and Lee Atwater are famous for perfecting the strategy for Republican candidates.
In 2005, then-Republican National Committee Chairman Ken Mehlman famously apologized to the NAACP at its national convention for trying to lure white voters by exploiting racist beliefs. "Some Republicans gave up on winning the African American vote, looking the other way or trying to benefit politically from racial polarization," Mehlman said. "I am here today as the Republican chairman to tell you we were wrong."
Sadly, many candidates continue the practice of wink-wink racism to this day, by campaigning against "welfare mothers" and (presumably black) teenage mothers and in support of potentially discriminatory and costly voter-identification laws, despite overwhelming evidence that it is excessive and unneeded regulation. This continued use of the southern race strategy Mehlman apologized for perhaps explains the GOP's ongoing challenge to diversify its ranks.