I'm gonna go against the grain here and say that you shouldn't worry about this at all, and you should write your story as you want to write it.
There are entire places and demographics full of people who don't consider 'retarded' to be an offensive term. Sometimes this is just because the word has evolved in a different way for them, and it doesn't carry the same kind of baggage it does to certain other groups. Sometimes it's because they're part of a group or demographic that doesn't consider it a bad thing to insult or belittle someone with mental illness. Sometimes it's because they just don't think about how other people might interpret their words, and instead rely solely on their intentions.
Same goes for most of the words that are considered 'offensive' here in the states: nearly every one of them is used as a part of regular vernacular to some degree or another in other parts of the world and that is okay.
Different cultures, demographics, and geographical locations are going to have their own set of social standards for how language gets used, and to be completely frank (maybe this is just the slowly-growing boomer in me talking) it feels to me like most people who are actually getting offended at things like this are idiot children with their heads far enough up their own asses they can taste what they ate for breakfast this morning.
If your readers aren't going to bother to understand where you're coming from, how you and your culture use language, and what you're intending to say with your work, then they aren't worth bothering with.
Telling a story is a two-way street; you as the author are laying out a plot for the reader to follow, but if a reader isn't willing to put in some effort to read, understand, and think about the story they're being told, then you aren't to blame for that. If someone is going to get hung up on a single word being used at all regardless of context, then they aren't engaging with your story and probably never actually cared all that much to begin with.
Of course, it can go the other way with the author expecting too much of their reader and finding that balance is like 90% of what makes being a good storyteller difficult, but that's a whole separate discussion that isn't relevant here.
Additionally, Is the character using the word supposed to be a perfect paragon of moral fortitude? do they do no wrong, have no flaws, make no mistakes? Literally every person fucks up in some way or another, and it isn't uncommon for people to be crude, crass, or careless with their language. Even if the character is a good person, even if they're the protagonist and we're supposed to see them in a good light and sympathize with them, the idea that using an offensive word at all is an indictment of the story as a whole is absolutely laughable to me.
Sometimes good people have bad ideas in their head, do bad things, or just generally aren't perfect. This is good. this is what makes stories interesting.
If it serves the comedy, the scene, the tone, the mood, the characters, or any other aspect of the story, then no word should be off limits. (I can't wait to see the response when I have a character drop the T-bomb AND the gay-F-bomb back to back in my comic later on down the road...)
It's not JUST 'bad guys can say bad words because we're supposed to hate them', nearly any character can be made sympathetic with the right lens on the story, and nearly any character can be framed as the villain in the same way. Stories are about people, and people are flawed in all kinds of different ways, so telling the story with those flaws intact makes the characters in your story feel more real and engaging.
As an addendum, in this particular case, I take issue with how overboard people have gone with this specific word. To 'Retard' something literally means to slow it down. It's why we have flame retardant materials to keep fire from spreading and retardant mediums for Acrylic paints to slow their drying time. referring to people with Down's Syndrome or other developmental disabilities was (originally) just describing them accurately; they learn more slowly, and therefore their mental capacity has been, by definition, retarded in the literal, original sense of the word. I understand that the term's use and connotation changed over time and it's considered offensive now, so yeah, I don't use it myself, but it actually is a case of words being used for their intended purpose. I accept it, but I don't exactly understand it.
Same goes for 'dumb'. The word literally means an inability to speak; you can be 'struck dumb' by a shocking event. It refers to an inhibited capacity for communication, which often resembles or is a result of a lack of intelligence. No idea how that one got considered offensive.
Meanwhile 'lunatic' is still totally fine, even though the very origin of that word is in reference to acting irrationally due to the lunar cycle. It's an inherently mysoginistic term that implies a woman being on her period is comparable to genuine insanity, but nope, practically nobody has a problem with calling someone a lunatic. it just means 'acting irrationally' and has no baggage associated with it whatsoever.
my point is that language is dumb and weird and confusing (especially English), and nitpicking exact individual words to avoid offending anyone is an ultimately pointless endeavor, because in 10 years, what words will or won't be considered acceptable could have changed completely. As long as you don't write with the intention of belittling or harming or upsetting anyone in real life (well... even that's up for debate depending on the kind of story you're telling, but I digress), then use the language that suits your story best, and don't worry about people who are going to engage with you in bad faith and assume things about you as a person based on a surface-level reading of your fictional stories.