A lot of the time they're not meant to. They're meant to figure out whether he's a bad programmer (or bad cultural fit, or something else bad).
The cost of hiring someone bad is way higher than most people would guess. I've come to believe that in many cases the questions asked in an interview almost don't matter - they're just there to give you an opportunity to fail, or to say something incredibly dumb or ignorant or obnoxious so that the interviewer can quickly reject you and avoid an expensive mistake.