A prisoner is told that he will be hanged on some day between Monday and Friday, but that he will not know on which day the hanging will occur before it happens. He cannot be hanged on Friday, because if he were still alive on Thursday, he would know that the hanging will occur on Friday, but he has been told he will not know the day of his hanging in advance. He cannot be hanged Thursday for the same reason, and the same argument shows that he cannot be hanged on any other day. Nevertheless, the executioner unexpectedly arrives on some day other than Friday, surprising the prisoner.As with the Monty Hall problem, it just makes no sense at all at first sight. But now, after talking it through at length with my son, the paradox has slowly vanished. (Disappointingly, since there's something satisfying in an impossible paradox.)
(Wording taken from the Wolfram Mathworld site)
The key is that you have to include the possibility that he will not be hanged and/or it will not be unexpected. If you don't include that possibility he can't be hanged unexpectedly, which contradicts the fact that you have not included those possibilities. So you have to include them, and by including them, you allow for the hanging to happen and be unexpected.
(And actually I think that the telling of it from Mathworld above is slightly misleading, because it can be on Friday that he's hanged. If he gets to Friday he'll know that either the judge was lying about him being hanged or about it being unexpected. Since he doesn't know which applies, he still doesn't know whether he'll be hanged that day or not.)