I'm reminded of a moment in the series where the writers recognized that they were crafting a televised Bible for American culture (although, I can imagine its axiomatic humor has reached beyond and enriched the lives and souls of other peoples). While this particular exchange refers more specifically to religion and not issues of race, it's a very relevant piece to reflect on when thinking about humor and offense:

Episode: Homer the Heretic (Homer is conversing with Apu about the statue of Ganesha sitting on the counter)

Homer: Hey, Ganesha, wanna peanut?
Apu: Sir, please do not offer my god a peanut.
Homer: No offense, Apu, but when they were handing out religions, you must've been out taking a whiz.
Apu: (angrily) Mr. Simpson, please pay for your purchases and get out and(cheerily) come again!

Much of the humor in the situation, granted, derives from the use of the characters as stereotypes, but focus on the reactions to the lines (yours and the characters). Why might Homer's first line be considered amusing (while clearly Apu does not)? How is his second line different from his first? Does Homer now become a bigot or is he just an asshole?