This joke is a play on the concept of logical thinking and how logicians approach problems.
When the bartender asks if anyone wants a drink, he's essentially asking if at least one of the three logicians wants a drink. The first logician doesn't know if the other two want a drink, so he can't answer the question with a definitive "yes" or "no." So he says "I don't know."
The second logician hears the first one's answer and concludes that the first logician must want a drink, because if he didn't, he would have said "no" (since he would know that at least one person—himself—doesn't want a drink). However, the second logician still doesn't know if the third logician wants a drink or not, so he also says "I don't know."
The third logician hears both answers and realizes that since neither of the first two said "no," they both must want a drink. So he can confidently say "yes" to the bartender's question, meaning at least one of them wants a drink. The humor lies in the fact that the logicians are using their logical thinking skills to answer a simple question about ordering drinks in a roundabout way.