Context – especially in literature – is king. Words have value and meaning and – if used correctly – shock value.
Like much in life it depends on context and audience.
If the story is set in a more casually racist time and place, the N-word would have in fact been thrown around casually – especially by racists, and would have strongly underscored the time and place and have the shock value of how that racism would have been accepted as a norm. Notice that I didn’t say “the” norm – although, the racism in the deep South during the Civil Rights era and before would have been taken for granted as the norm for the time and place – but, perhaps, not the norm in other parts of the country.
If the story is set in a more contemporary time and place, then the contrast to other characters would be again be useful to drive home the point of the character’s racism. Or in the case of black people, a term of endearment.
There is a caveat here though: Do not use the N-word by itself to show racism, the trait has to be backed-up by actions that confirm that trait. Throwing the word around is not enough in a work of fiction.