Why they ask it:
Sometimes, the interviewer will ask it by mistake because they’re just trying to develop rapport with the candidate. In some rare instances, the interviewer may be attracted the candidate but most people in a position that requires interviewing are professional enough to never do this.
In other cases, the interviewer might be probing for information about the candidate’s commitments outside of work. In some people’s minds, single people are typically able to work longer hours, travel more often and can put their jobs ahead of their personal lives.
In the case of female candidates, an employer may be trying to figure out if the candidate is planning on having a baby in the near future. Some employers have been burned in the past by hiring someone only to have them go on maternity leave shortly after they start.
How to handle it:
The key to handling any illegal question is to do so in a manner that doesn’t harm your chances in landing the job. Yes, you could file a complaint or threaten to sue the company to force them to give you the job, but I can guarantee that you’ll be unhappy there if you take that route.
So instead, figure out what the motive is. If it’s just part of a casual conversation and you don’t think your answer will harm you, then feel free to answer it. If you fear your answer might harm you, then say something like “I like to keep my business and personal lives separate and I don’t see anything in my personal life preventing me from doing a great job here.” Always be positive and upbeat with your answer.
If the interviewer presses for a concrete answer (or becomes annoyed at your answer), then you need to let them know that they’ve asked you an illegal question. You can do so in a nice way by saying something like “I’m not sure if you’re aware of this, but there are certain questions that are illegal to ask during a job interview.” Make it sound like you’re looking out for them.
Regardless of whether you’ve been asked an illegal question, if the questioning makes you uncomfortable, take your skills elsewhere. If you feel uneasy during the interview, imagine how you’ll feel on the job.