Usually it's a public interest issue.
I'm admitted to practice law in NY. I presume you are not. It protects the public best if a person who is educated in this area (and licensed) undertakes the representation of others, versus someone who is not. I'm not talking about representing yourself. What I mean is if your neighbor got a DWI or whatever.
Same with an RN or a driver's license (although keep in mind there are some forms of licensure that really don't measure competence or education and instead are a revenue-generating activity for a state or local government).
People have individual exclusives all the time, and those don't violate Equal Protection. My husband and I are the only owners of our home. It's not a 14th Amendment violation if we are the only ones who can sell it, and you cannot.