In most RPG's, NPC's serve as the quest givers or shopkeepers for the game world. They can also take on the role of AI-controlled party members, and are commonly there to propel the story or mission forward.
NPCs were made popular in the 70's with the creation of Dungeon and Dragons. These characters were added to allow the Game Master (GM) the ability to interact with the player characters. This led the video game industry to borrow from this idea to have the developers create NPCs where they needed to move the story along by interacting with the player on a more dynamic basis.