Hence manufactures would produce cars in volume and sell them to the dealers. The dealers who made that investment in buying those cars then sold them for a profit. Dealers are protected by these same laws usually geographically. This in some way insulated the manufacturers from market fluctuations and allowed more efficient factories.
Plus you cannot pass up the test drive. Really, would you buy a car without a test drive? Dealers took that job which does incur some risk of loss. It was a good idea at the time. Society was not as integrated as it now, you could not just look up your car in any sense of the word we do now.
Just like other franchise setups, they are entrenched and not necessarily bad. Would you rather be beholden to a large auto maker or have a small shop to talk to in the event of a problem? A sole dealership will be more likely want to create a long term relationship and would work to solve you problems, a distant manufacturer who is large could afford to blow you off.