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.