The way I see it, even if those biases exist, the racist ones don't really have much of a choice but to be polite. In game, the reason is usually because the racists don't really have much choice but to accept the aid of these adventurers, along with a healthy does of fear. If your only option to stop the bandits is that Tiefling, you pay them and hope they never bother you again. If the Tiefling comes back after killing every single Bandit, you pray they don't murder the town and treat them very politely to avoid being killed. Out of game, its because I find players tend to take personal slights from NPCs very, very personally, and will go out of their way to harm that NPC. I'm no different in that regard as a player.

Pretty sure I've only ever had one NPC that avoided being punished for screwing with the players. And the only reason they didn't punish him is because they realized doing so would either be more trouble than he was worth for them. The NPC in question was an Ancient Copper Dragon that sold joke magic items that were cursed. His entire hoard was made up of nothing but Copper Pieces and a single Electrum, and he paid for everything in Copper Pieces cause he found it hilarious. They didn't want to try and take his hoard cause they didn't have a way to carry 55 million Copper Pieces, and they didn't want to subject some poor officer to having a huge fine paid in pennies. XD