Why is the original Pandemic set for up to 4 players when there are 5 role cards?
When the game is started the roles are shuffled together and each player is dealt a random role. Having more roles then players allows for some greater variations in the game as you will not always get the same roles in every game which can change how you play the game. You can see in the rules how it deals with the extra roles. Also it should be noted that in the current edition there are 7 roles for 4 players in the base game.
After you play the game a number of times, you'll notice that the combination of roles affects the flow of the game. The 5th role increases replay value and prevents the game from becoming too repetitive.
Pandemic has expansions, however, which allows for more players. One such expansion, "Pandemic: On the Brink", has 5 players and includes 7 new role cards.
The base game and subsequent expansions rely on additional role cards -- as well as other added game mechanics -- to keep the game interesting.