Gambler's fallacy is a psychological misinterpretation of how repeated random events work in real life. Although its application does not necessarily involve gambling, the term is drawn from the tendency in gambling to perceive winning or losing "streaks," or to believe that an upcoming gamble will win or lose, based on recent results rather than based on the actual statistical probability of what is in fact a random event.
There are actually two separate psychological mistakes which are often made in relation to series of statistically random events. The first, which is not as commonly referred to as gambler's fallacy, is the tendency to believe that recent iterations of the game or event in question can be used as a direct guide to future iterations. If, for instance, someone has won several times successively, this is taken as an indication that they are having a "lucky" night and that if they continue gambling they will probably win even more. Alternatively, someone who has lost repeatedly may conclude they are having an "unlucky" night and should stop before they lose more money.
The second set of perceptions, which are more commonly known as the "gambler's fallacy," actually work in reverse. These note that, over time, there should be neither good nor bad luck: everything should average out. A flipped coin (unless it is weighted) should, overall, come up heads about half the time, and tails about half the time. If it comes up heads several times in a row, it is easy to conclude that a tails toss is now "overdue" and is about to happen. Put in a gambling context, an unusually lengthy string of losses may be seen as an indication that one should actually keep gambling, rather than stop: in other words, that a win is statistically "overdue" and therefore it would be a bad time to quit. The reverse is also true: a slot machine which has just awarded a large sum to another player may be seen as having "exhausted" its winning spins and therefore is less likely to give the same reward again.
Speaking in statistical terms, we know that all of these perceptions are actually entirely false. This is because, even where we know what the probability of a given outcome should be, and even though over time a long series of iterations of a game should reflect that probability, the previous results of a random game actually have no impact on the results the next time it is played. The fact that a pair of dice came up showing two sixes several times in a row is statistically unlikely, but it does not make it any more or less likely that the dice will show a pair of sixes (or not show a pair of sixes) the next time they are rolled. The next time the dice are rolled, there will still be a 1-in-36 chance of two sixes appearing, just as there was each previous time, and just as there will be each subsequent time. After a string of bad luck, one is not "overdue" for a win: the odds continue to be the same as they were before.
It is important to remember, however, that not all situations are examples of the gambler's fallacy - because there are many situations, including within gambling, where the results are not completely random, without being influenced by past games. This is true in card games, for instance, where players make decisions not only on the basis of the cards in their hand, but on the basis of what they observed the others doing with previous hands.