Put yourself in the shoes of a hiring manager for a moment. You know that a candidate is going to present their best possible self to you, but you also know that no person is perfect. However, in that kind of situation, asking them directly to talk about their weaknesses seems like the least likely way to get an honest answer. And they're certainly not going to volunteer a laundry list of their faults if they're a candidate worth hiring.
So why do interviewers ask this question?
They're not expecting to find out every possible downside to hiring you. That's not realistic. But asking this question still allows them to find out some valuable information about you as a candidate and as a potential employee.
First, if you provide an honest, concise answer, it demonstrates that you've given some thought to this question yourself. Having an employee who is self-reflective is valuable; it means they're going to correct many of their mistakes without their managers having to sit down with them and provide feedback.
It also demonstrates humility. If you provide a real (though tangential) answer, rather than a fake strength-as-weakness answer, then they can have some confidence that you're not going to be an overconfident, "I can do no wrong" type of employee.
It provides some idea of whether self-improvement is important to you. As I've said before, eagerness and passion go a long way toward helping you stand out as a candidate. The candidate who has already taken the initiative to improve a weak area in concrete ways illustrates an eagerness to learn, grow, and contribute as much as possible, which is far more attractive than a candidate who simply says, "This is what I'm not very good at" without seeming too concerned about doing anything about it.
Finally, it is an easy gauge of your general preparedness. The "weakness" question is one of those classic interview questions that, if you've prepared for an interview at all, you will almost certainly be prepared for. A candidate who is caught off-guard by this question is one who probably didn't do much preparation at all for the interview, meaning they either don't care very much about the position or they're so overconfident they didn't think they needed to prep.
When crafting and practicing your possible answers to the "weakness" question, keep in mind what the interviewer is really trying to find out.