Twain was a master at dialects and accurately capturing the spoken language from certain regions. Even though the n* word (as you put it) may not have been accepted in some parts of the United States, you can bet that it was widely used in the deep South, especially during the time period within Twain's novels. I think that sometimes it is easier for people to paint a rosier picture of history than is historically accurate to avoid facing the reality of a deeply prejudiced South and an enslaved minority. Even after the end of the Civil War and all of the Civil Rights Movement, the N* word still persisted in the deep South. If you look at other deep South writers both black, like Anne Moody for example, and white, the common usage of the N* word remained prevalent.