There are only seven possible arrangements of the hats among the three people:
r r r
r r b
r b r
r b b
b r r
b r b
b b r
(In case you didn't understand that, "r b b" means, "the first person has a red hat on, and the second and third people have blue hats on; "r b r" means, "the first and third people have red hats on, the second person has blue.", and so on. In case you didn't understand that, you should seriously consider never breeding...)

Anyway, since everyone can see two red hats, they can immediately eliminate all combinations with two blue hats, leaving

r r r
r r b
r b r
b r r

So the first person's response is utterly unhelpful to the second person, who still has no way to determine what color hat she is wearing.

Now it's the third person's turn. Immediately, she knows that the only combinations are r r r and r r b. But she knows that if it were r r b, that the second person would have been able to give an definitive answer, so the arrangement must be r r r, and thus the third person can answer "I know."

But wait! How would the second person have been able to determine her hat's color, if the third person's hat had been blue? Well, the only possible combinations for that have been

r r b
r b b
b r b
of which she could have eliminated b r b. (The first person isn't wearing a blue hat!) She could have then eliminated r b b, because if that had been the arrangement, the first person would have known her own hat color immediately!

fun, huh?

Two interesting variants on this problem starts with the same setup, but differ in that, we, the puzzle-solvers, are not given the hat colors.

  • The first person says, "I don't know", the second says the same, and the third says, "I know." What color is the third person's hat?
  • The first person says, "I don't know", the second says "I know", and the third says, "I know." What color is the third person's hat?

Here is a list of all the configurations, and the responses they generate: ("?" means "I don't know", "!" means, "I know")

setup    responses
r r r -> ? ? !
r r b -> ? ! !
r b r -> ? ? !
r b b -> ! ! !
b r r -> ? ? !
b r b -> ? ! !
b b r -> ? ? !
So we can see, if the first two answer negatively, the third's hat is always red. If the first answers negatively and the second answers positively, the third's hat is always blue.

phew....