Randomness is a common factor in many electronic based games. This can add a sense of chance and uncertainty to otherwise solely strategic games, and even out a contest between players of different skill levels.
Randomness is used as a mechanic for several reasons. An example will better illustrate them:
In game A, the player finds that whenever he kills a certain type of enemy, the enemy always drops the same loot. It's as sure as the sun rising. In game B, the player finds that the same enemy will randomly drop the same loot, but half as often, and about twice as much in quantity. Effectively this works out to the same amount of loot as game A, so there's no balance change needed. But it has been found  that players are less likely to burn out when there's an element of randomness involved.
If a quest objective has a requirement to collect 10 macguffins, and there are several quests with this similar requirement that the player has stacked, he will find it inherently more interesting if on some of the quests he has to only kill 5 enemies to collect the 10 items, and on others it takes closer to 10. This uncertainty sets up small cycles of tension and reward. These micro climaxes are enough typically to maintain a state of play called being in the zone.