NPC Alignment (DMG)

Just as a well-played character acts within the limits of his alignment, NPCs should act consistently with their alignments. Judicious and imaginative use of NPCs is what creates a believable fantasy world.
Alignment is a quick guide to NPC and monster reactions. It's most useful when you don't want to take the time to consult a page of tables and you haven't devised a complete personality for every casually encountered NPC. NPCs tend to act in accordance with their alignment (though they are no more perfect in this regard than player characters).
Thus, a chaotic evil gnoll tends to react with threats and a show of might. It considers someone who appeals to its compassion as a weakling, and it automatically suspects the motives of anyone who tries to be friendly. According to the gnoll's view of society, fear and bullying are the keys to success, mercy and kindness are for the weak, and friends are good only for the things they can provide—money, protection, or shelter. A lawful good merchant, meanwhile, would tend to hold the opposite view of things.
==The Limits of NPC Alignment==
Remember, however, that alignment is not personality. If every lawful good merchant is played as an upright, honest, and friendly fellow, NPCs will become boring in a hurry. Just because a merchant is lawful good doesn't mean he won't haggle for the best price, or even take advantage of some gullible adventurer who is just passing through. Merchants live by making money, and there is nothing evil about charging as much as a character is willing to pay. A chaotic good innkeeper might, quite reasonably, be suspicious of or hostile to a bunch of ragged, heavily armed strangers who stomp into his inn late at night. A chaotic evil wizard might be bored and happy for a little companionship as he sits by the inn's fire.
To create memorable NPCs, don't rely solely on their alignment. Add characteristics that make them interesting, adapting these to fit the character's alignment. The merchant, perhaps feeling a little guilty about over-charging the adventurer, might give the next customer a break on the price. The innkeeper might be rude to the adventurers while clearly being friendly to other patrons. The chaotic evil wizard might discover that, while he wanted some companionship, he doesn't like the company he got. He might even leave behind a token of his irritation, such as bestowing the head of a donkey on the most annoying character.