The Setup
Two suspects are arrested and kept in separate rooms, so they can't talk to each other. The police don't have enough evidence for the main charge, so they offer each prisoner the same deal. If one confesses and the other stays silent, the one who confesses goes free and the other gets 3 years. If both stay silent, they each get 1 year on a smaller charge. If both confess, they each get 2 years.
Payoff matrix for the two prisoners, in years in prison.
Why Both Prisoners Confess
Look at it from prisoner A's side. If B stays silent, A gets 0 years by confessing instead of 1. If B confesses, A gets 2 years by confessing instead of 3. Either way A is better off confessing, so confessing is a dominant strategy. B is in the exact same position, so both confess and both end up with 2 years. This outcome is the Nash equilibrium, since neither prisoner can do better by changing only their own choice.
The problem is that both staying silent would have been better for both of them, 1 year each instead of 2. Each prisoner acting in their own interest leads to a worse result for the two of them together, and that's the dilemma.
Where It Comes From
The game was first set up by Merrill Flood and Melvin Dresher at the RAND Corporation in 1950. The mathematician Albert Tucker later gave it the prison story and the name that stuck.