It is practically illegal because relying on the answer to the question in employment decisions is illegal, and if you ask it in an interview, and you are challenged, it is going to be very hard to convince a jury or judge that it did not factor into your decisions.
It's not so much an "illegal question" - it's asking about something that's illegal to take into consideration when making hiring decisions. So there's no legitimate reason to ask it and any answers can't be used.