Apu being a morally upstanding citizen in a show where there's something otherwise wrong with everybody is the joke. It implies that what's wrong with him is merely his racial handicap when everything else in-setting is going well for him.
Lol I never read Apu as being morally upstanding. Half the jokes at his expense are about him reusing month-old hotdogs or otherwise scamming folk. It's the sneaky foreigner narrative.
He's just cutting corners to get around his realistically described debts as a first generation immigrant. The most racial thing about it is him running the equivalent of a 7-11, but what they overshadow initially but detail later is over him being the owner of his own business. He has a Ph. D in Computer Science, a successful family, and he's been shown to be more spiritually tethered to his faith without being a politeness jutsu nazi bigot over it like Flanders does to sublimate his subconscious rage. Even in a town that's around 99% white (yellow?) where he is the extreme minority, the town treats him no differently over his race beyond curiosity over what's left of the customs he still practices.
He's arguably a role model if you look at the life he's led, but the way they'd present him being a successful achiever however usually had a beat in the timing that was meant to imply it was a joke.
Don't get me wrong, I think his character being written off the show was wildly disproportionate and that cancel culture is an insane. But not so sure he was ever portrayed as morally upstanding.
They would have kept Apu on board if it weren't for the voice actor deciding to quit voicing him. Ultimately where the writers couldn't be pressured, the V.A. could be apparently.
The racial sensitivity that was more present in the earlier writing went away once the majority of the original writing staff left. It was around this time that they racially tokenized a wife for him where his character authenticity began to decay in the writing.
Ę̵̚x̸͎̾i̴͚̽s̵̻͐t̷͐ͅe̷̯͠n̴̤̚t̵̻̅i̵͉̿a̴̮͊l̵͍̂ ̴̹̕D̵̤̀e̸͓͂t̵̢͂e̴͕̓c̸̗̄t̴̗̿ï̶̪v̷̲̍é̵͔