I think it was mostly a function of two things: regulatory capture by profit-incentivized doctors, and the labs not having (or wanting to have) consumer-oriented sales processes.
The internet has made the latter easier in a number of ways - making research easier for consumers to know what to order and interpret results, and offering COTS systems for commerce, document management, authentication, shopping carts, and inventory tracking.
I would bet that in most states, laws were less of an issue than the labs not wanting street-facing sales - same way some hardware companies only sell to distributors (i.e. street sales (and consumer support) are a pain in the ass vs curated partners).