Random number generators have much to do with Pokemon, as well as with any game with random elements. Since there is no such thing as randomness when it comes to computations, engineers have come up with the best psuedo-randomness they can. Currently, Pokemon does this by changing up its generator based on the current second in time.
Anyway, Pokemon uses this RNG to determine many things, from the way certain NPCs move, to whether a paralyzed Pokemon can move, to whether a Pokemon will be shiny.