The dealership system is to provide assurance to the buyer that a corporate entity under the authority of the state's regulators and law enforcement officers but also available to sell parts, perform warranty service, and repair the vehicle.
A dealer being willing to sell a company's cars serves as some assurance that the car manufacturer is stable, reputable, etc.
This all came into being during the big automotive industry boom in the 20's when car frames/powertrains were made by manufacturers and then a "coachworks" company would put a body on that..and both powertrain and coachwork companies were often in business just long enough to get some cars out the door before customers discovered poor workmanship, assemblies not designed to be repaired, non-standard fastener sizes and so on. It was common for people to buy a car, drive it home several states away (in an age where there was no interstate highway system!) and discover that their car was falling apart.
Oh hey, what does Tesla have problems with? Poor parts availability, warranty issues, long waits for repairs...
I wish I were exaggerating when I say Tesla was telling Model S owners that water getting inside the main drive unit (which contains not just the electric motor but the motor's power electronics) because of a faulty seal on a speed sensor was the customer's fault because they drove the car in heavy rain.
There is little distinguishing Elon Musk from the shysters in the 1920's that all these pesky regulations were written to address.