short for raccoon, 1742, American English. It was the nickname of Whig Party members in U.S. c. 1848-60, as the raccoon was the party's symbol, and it also had associations with frontiersmen (who stereotypically wore raccoon-skin caps), which probably ultimately was the source of the Whig Party sense (the party's 1840 campaign was built on a false image of wealthy William Henry Harrison as a rustic frontiersman).
The insulting U.S. meaning "black person" was in use by 1837, said to be ultimately from Portuguese barracoos "building constructed to hold slaves for sale." No doubt boosted by the enormously popular blackface minstrel act "Zip Coon" (George Washington Dixon) which debuted in New York City in 1834. But it is perhaps older (one of the lead characters in the 1767 colonial comic opera "The Disappointment" is a black man named Raccoon). Coon's age is 1843, American English, probably an alteration of British a crow's age.