Let the three men be named as "A", "B" and "C". Before I tell you the answer, keep this in mind that all the three are wise and the third could guess correctly only after having heard their responses. Let "C" be the one to have answered correctly.
1. Let us take the case of "A", he has raised his hand which implies that he sees a red dot on the forehead of either "B" or "C" or both.
2. Likewise, "B" has raised his hand. Thus, either "A" has a red dot or "C" has a red dot or both of them have red dots.
3. Finally, "C" has also raised his hand which implies either "A" or "B", or both of them, have red dots.
4. Suppose "A" has a blue dot, then from steps 1, 2 and 3 it becomes clear that both "C" and "B" have red dots (Step 1: "B" has red dot or "C" has red dot or both have red dots. From step 2, "C" has red dot and from step 3, "B" has red dot - thus, both "B" and "C" have red dots).
5. Similarly, if "B" has a blue dot, then both "A" and "C" have red dots.
6. Lastly, if "C" has a blue dot, then both "A" and "B" have red dots.
7. This implies that there are at least two persons with red dots (all the three could have red dots but at least two of them definitely have red dots) while only one person may have the blue dot (there could even be no one with a blue dot).
Once this conclusion is reached, the next step is easy after listening to the responses of the other two. The first accepts defeat since he can see two red dots and, so, is unable to tell whether he has a red dot or a blue dot. Same is the case with the second. So, all the three are seeing two red dots - this is possible only when all of them have red dots on their foreheads. The Master has painted red dots on everybody's forehead and "C" has answered correctly after hearing the resonses of the other two.