Same for any profession.
It’s not something regular people are using consistently so they have researched the people in advance. They usually have to scramble when they need a lawyer. And it’s very hard for a lay person to identify whether a lawyer did a good job or not.
But even when it comes to bigger firms which do have the resources to find good lawyers, there’s a different advantage to heavy handed licensing. The fact that the law depends extremely heavily on lawyers being largely honest especially when it comes to stuff like discovery and maintaining confidentiality. Licensing is one of the strongest tools has to ensure that.