In real life, everything people do is for a reason, even if they are not consciously aware of it: motivation is the source of behaviour. If we can give NPCs a reasonable set of motivations, they can act in consistent ways that are more flexible than scripts and more believable than random activity.
So ... why does anybody do anything, ever? To answer this we will turn to a deeper question: what does it mean to be human?