“Raccoon” comes from the Algoniquan/Powhatan word arahkunem, meaning “he scratches with the hands,” which was first clumsily adapted by English colonists including John Smith. (Also related, “trash panda” is from the internet, circa… 2016 probably.)
“Raccoon” is often shortened to “coon,” which was also a nickname for members of the American Whig Party in the mid-1800s thanks to its association with frontiersmen and its raccoon symbol. The more nefarious use of “coon” as an insult for African American people is most likely not from “racoon,” but from the Portuguese barraca, “slave depot,” a use that was popularized by a blackface performer.
The original English word for raccoon was arocoun, from the Algonquian/Powhatan word for the critter, arahkun. This word was a nominal form of the verb *arahkunem*, meaning “he scratches with the hands,” referring to the way raccoons scrabble for food and tidbits with their little hand-like front paws.
Because it was difficult to pronounce in English, early adaptations of the Native American word were documented with all manner of bizarre letter-salad spellings, including *raugroughcum* recorded by Captain John Smith in his 1608 account of the Virginia colonies. Other colonists recorded it as *rackoone* or *rockoon* before the spelling was (mostly) standardized around 1672. I say “mostly” because it’s also documented as “racoon” in some texts thereafter. Further details on these spellings can be found in the book *English: History, Diversity and Change* by David Graddol.
Coon, of course, is often used as a shortening of “raccoon,” most commonly known to me from the stupefyingly tragic Where the Red Fern Grows (which, if you weren’t required to read in junior high, I would advise avoiding like Ebola unless you crave clinical depression).
“Coon” was also a nickname for the American Whig Party in the 1840s thanks to its (temporary) raccoon symbol, which was inspired by the party’s association with stereotypically coonskin-capped frontiersmen, and the fact that early Whig Party leader and 9th U.S. president William Henry Harrison was often thought of as such a frontiersman. On the contrary, he was rather wealthy and not quite the rustic fellow of Whig lore, but he did breed horses, advocate for policies that benefited frontiersmen, and command armies on the American frontier during the Northwest Indian War, notably fighting in the conclusive victory at the Battle of Fallen Timbers in 1794.
As you probably know, “coon” has another, grimmer meaning from American history as well. I had always assumed that the word’s use as an insult for black people came from “raccoon,” for whatever reason, but interestingly enough, that’s most likely not the case. (It’s possible that it was influenced by the the 1767 colonial comic opera “The Disappointment,” which included a black lead character named Raccoon, but this is unlikely because the play was not particularly popular.)
Instead, it’s more likely that the word’s pejorative sense arose around 1837 from the earlier word *barraccoon*, which came from the Portuguese word *barraca*, meaning “slave depot, pen or rough enclosure for black slaves in transit in West Africa, Brazil, Cuba.” It was also popularized by George Washington Dixon, an actor and newspaper editor who was widely known for his blackface performances during Andrew Jackson’s administration and through the early- to mid-1800s. His most popular blackface performances included the songs “Zip Coon” and “Coal Black Rose.” (Note: Obviously these songs are heavily racist.)