Uber and Lyft, we hardly knew you.

As the California attorney general pursues its lawsuit against these ride-sharing companies, to force them to comply immediately with the state’s virtual ban on using contractors as workers, the firms had announced  last week that they would temporarily leave the state as they retool into smaller operations.

The courts gave them a last-minute reprieve , but their long-term plans here remain uncertain. Sadly, state officials had been intent on punishing these companies—even before voters have a say. At the very least, the state should have waited until the public decides on the matter in the Nov. 3 election via Proposition 22 . That measure would carve out a contracting exemption for independent drivers and provide them with health-care and other benefits.

If voters reject Proposition 22, these groundbreaking services might really go away. Their crime? They’ve been too successful at serving consumers and providing flexible employment opportunities for hundreds of thousands of California workers. That has provoked the state’s politically muscular unions , which see a threat to their preferred work model—an antiquated system of inflexible 9-to-5 schedules, factories, offices and union shop stewards.

The unions can’t compete, so they must destroy what others have freely chosen. It reminds me of economist Walter Williams’ well-known quotation : “Prior to capitalism, the way people amassed great wealth was by looting, plundering and enslaving their fellow man. Capitalism made it possible to become wealthy by serving your fellow man.” These companies serve us, but the Legislature prefers looting and plunder.

I’m a slow adapter to technology, so I still recall my amazement when a friend introduced me to a cool alternative to slow, grimy, and pricey taxicabs. We were waiting to go to dinner while at a convention. Within minutes, an Uber driver showed up in a comfortable, clean, and late-model car, and inexpensively took us to our destination.

No big deal, right? But this simple system, which we now take for granted, is the result of amazing creativity, private investments, and voluntary arrangements. That’s how free markets work. Someone comes up with a better mousetrap and, as long as the government stays out of the way, the companies rise or fall based on their success attracting customers.

Think of how transportation services have improved lives. Elderly people have newfound mobility. They can easily get to doctors’ appointments and whatnot. Drivers deliver almost everything to our front door, from groceries to auto parts. After Austin, Texas, banned Uber and Lyft, drunken-driving arrests reportedly increased . As Williams noted, companies succeed by serving us.

I talk to drivers all the time—and they express satisfaction with their work arrangements. By the way, no one has forced them to take these jobs. The vast majority work limited hours , as they earn extra cash between other opportunities. Many independent workers of all types earn more piecing together various gigs than working only for one company.

We know what’s best for ourselves, even if Assemblywoman Lorena Gonzalez, the San Diego Democrat who authored the contracting-ban legislation (Assembly Bill 5 ), thinks she knows better. Her Twitter jabs at freelancers who have lost their jobs – they’re “not good jobs to begin with”—display an almost comical caricature of a “let them eat cake” legislator. Yet think about what happens if—or when—these services go away. Since January, when the law went into effect, companies have been eliminating bushel-loads of freelance jobs or shifting them to workers in other states.

Sorry, but one can’t create high-paid jobs by legislative fiat. The market does a remarkably good job of improving the lot of workers. It obviously has a better track record at doing this than the California Legislature . In the market economy, consumers come first—but workers’ fortunes rise in the process.

Look at Gonzalez’s home city of San Diego. As I’ve reported here before, prior to ride-sharing, residents were dependent on taxis. A 2013 report  from the Center on Policy Initiatives found that “taxi drivers earn a median of less than $5 an hour” and “virtually no drivers have job-related health coverage or workers’ compensation insurance.”

Drivers spent their time paying off cab owners’ inflated permit fees—and had little chance of becoming owner-operators because government only issued a restricted number of “medallions.” By contrast, a recent study  about ride-sharing in Seattle from Cornell University found Uber drivers earned an average of $23.25 an hour, which is close to the city’s median wage and is nearly 50 percent more than taxi-driver earnings.

Killing ride-sharing will not improve the plight of drivers. Still, the fundamental issue doesn’t center on worker benefits. It’s about the freedom to pioneer technologies and the ability of consumers to benefit from them. I don’t believe the future of any industry ought to be dependent on a popular vote , but at least California voters still have a chance to save these services.

This column was first published in the Orange County Register.

Featured Publications