When an employer is recruiting for a new position, candidates may arrive via a number of vectors: people considering internal transfers, responses to job advertisements, personal referrals, company recruiters, outside agencies, and so on. In the cases of internal candidates or personal referrals, there is an implicit expectation that these candidates will be 'given a chance.' Even if the individuals would not otherwise have slipped through your resume sieve, it's expected that you will give them an hour of your time. Granting an interview with little to no hope that it will turn into an offer is the 'courtesy interview.'
Some candidates take the process very seriously, which can be either encouraging or pathetic depending on how far away they are from suitability. These are the easiest to handle as it's similar to any other interview, except that you will probably play a bit more softball than usual. There's no point in aggressively exposing the candidate's flaws and engendering bad feelings.
Others seem to expect a 'free ride' and can become flustered, offended, or even angry when they are treated like 'any other candidate' and are expected to demonstrate competence and experience. Some of my worst interview experiences have been with referral candidates who thought their interview was a formality. These candidates may need a reality check, and you'll need to decide if you want to be the one to administer it. It may not be worthwhile, and you may choose to just close things out in order to keep the peace.
Assuming that there isn't an entirely unexpected diamond in the rough, after thirty minutes or so, it's time to shift from interviewer to counselor. You should have a good read on the candidate's self-awareness. If they've realized that the jig is up, then friendly advice on skills development and resume crafting might not go amiss. If they are hopelessly deluded, then a careful 'I have a lot of interviews to do and I'll let you know how things develop' may be your best option.
Hands down, the worst part of the courtesy interview is dealing with the disappointed friend/co-worker/relative afterward. There's really no way to finesse it, you'll have to say that the individual doesn't have the skill set you need for the position. If the job goes unfilled afterward, things can get very awkward. But nobody wins if you make the wrong hire.
If you think that you are on the interviewee's side of the courtesy desk, please understand that the interviewer has been placed in an awkward position. They need to give you a fair shake, to be sure, but every interview they do is time away from a project that is probably already in the crapper because of the open hire. Present your skills and experience, read the body language, and try to learn from the interview. Don't give up too soon, though: if you do want the job, be sure to say so. Sometimes that can tip the balance if there's already hope. If not, be prepared to ask 'What can I do to get ready for a role like this?' if it's obvious that it's not going all that well, and be sure to express your appreciation for the interviewer's time. The person who referred you stuck their neck out for you, don't make things any more awkward for them than you can avoid. After all, another chance could come with a more suitable role, and you'll want to be considered when that time comes.