I'm not black, white, or American, but if I have a type it runs to black women. As a kid I watched a lot of hip-hop videos and read a lot of National Geographic. I can't find it, but I'd swear they had an article on "The Bare-Breasted Maidens of the Ookaboolakonga."
Anyway, I have put some thought into this.
In a historical context it's totally appropriate. Even the most well-meaning character is going to use it, and innocently too.
In a modern context, it's appropriate for racist characters to use it. It would be weird if they didn't. However, the work's internal morality must make it clear that this is not okay.
In a modern context, it's also appropriate for black characters to use it, but they must be well-written characters. We don't want to fall into literary blackface. We must approach this with sensitivity and care.
Is it appropriate for a non-black character to use the word, when the setting is modern and they're not being portrayed as racist? It's possible, but it takes a lot of work. So much that you either have to make it central to the narrative or else be a masochist of a writer. But it's doable.
The best example would be Don Rickles, the famous insult comedian. I don't know if he ever said "nigger" but the guy didn't hesitate to poke fun at you or your group. He got away with it because he never played favorites. More importantly, he absolutely radiated good-naturedness. When he insulted you, you knew that he liked you. He was that one elderly uncle who always pointed out your weight and embarrassed you in front of your girlfriend but at the end of the day you couldn't imagine family reunions without him.
It's about perceived intent. It's why comedians get away with jokes aimed at their own ethnicity even though they could very well be racist against themselves.
Will people be offended? Even if you did your due diligence and wrote a well-considered piece? Yes, a few people will be offended. But you should not be writing for them. I mean, they banned To Kill a Mockingbird for racist content!
Nothing should ever be taboo. No word or topic should be immune from criticism, or discussion, or ridicule. Because talking and writing about something is how we process it, but making it sacred is how we give it undue power over our minds.
Yes, the word "nigger" hurts people's feelings. Sometimes you have to be tactful and sometimes you have to strike at the heart. I wouldn't hesitate to use the word in my writing because I'd probably have good reason, but I'd hesitate to use it in front of strangers because they'd misread my intentions.
But that's only because I talk in a monotone. I greet my wife with a "Wassup nigga" all the time. It's okay. She knows I'm only prejudiced against Swedish people.