Airbnb is suing the City and County of San Francisco because a new ordinance makes the online home-sharing platform liable for violations of restrictions on short-term rentals. A court victory would get Airbnb off the hook, but property owners and renters would still be stuck with a statute that makes the city worse off.

Last year, a law went into effect that requires homeowners to register with a San Francisco agency if they rent out property for short-term use and to comply with limits on the length of time their property can be rented. To date, only about 20 percent of the 7,000 or so housing listings on Airbnb have complied.

Airbnb’s lawsuit, filed in federal court in June, argues that the city’s requirement violates First Amendment rights and ignores a 1996 federal law that indemnifies website operators when users post unlawful content. An Airbnb victory would shield the company from a $1,000 per-day per-violation fine, but would leave the enforcement battle to be fought between rental owners and the city.

Only permanent residents, who reside in San Francisco for at least 275 days a year, are allowed to rent out their home, and even then it must be their primary residence. Owners of rental apartments and vacation homes cannot use them for short-term rentals, and permanent residents cannot rent their vacant homes for more than 90 days.

Other cities, including New York, Anaheim, Calif., and Berkeley, Calif., have also introduced ordinances that place limits on rental units listed with sites like Airbnb. The problem with all of these ordinances, including San Francisco’s, is that they decrease the value that Airbnb can create for society.

“Sharing economy” platforms, which include Airbnb and Uber, find customers for valuable but sometimes idle resources and thereby slash the cost for those who own such resources — at least until their sales price fully reflects the discounted revenue stream from renting them out. These websites essentially mobilize intermittently “dead capital” and put it to use by creating value for others. Owners, renters and society as a whole are all richer as a result.

Ordinances like San Francisco’s restrictions on short-term rentals unnecessarily limit our ability to mobilize dead capital. Why should a vacation home sit idle when someone desires to use it while the owner is out of town? Why should a primary residence sit empty if its owner goes out of town more than 90 days when there are willing renters?

Airbnb’s critics worry that if short-term rentals are not restricted, this will raise housing costs by reducing the stock of permanent rentals. But if high rents and home prices are really their main concern, they should direct their attention to the main culprit: local government regulations.

In my book, “Housing America: Building Out of the Crisis,” co-edited with Randall Holcombe, we document the many ways in which government regulations have made housing less affordable. Land-use restrictions, minimum lot sizes and setbacks, impact fees, permit moratoria, “below-market” mandates, urban growth boundaries and other policies all limit housing supply and decrease housing affordability.

A classic study by economists Edward Glaser of Harvard and Joseph Gyourko of the University of Pennsylvania examined the effect of government restrictions on housing prices in several markets around the United States. They found that 90 percent of the difference between physical construction cost and the price of new homes could be attributed to government restrictions on development. Only 10 percent of the difference was due to the intrinsic scarcity of the land.

Municipal restrictions of short-term rentals are just one more misguided government disruption of housing markets. They leave valuable capital idle when it otherwise could serve consumers. Ironically, they help make housing less affordable by limiting an alternative income stream that can help owners better afford their homes.

A court victory for Airbnb would be a good first step toward housing affordability. But ultimately, curing the costly maladies of our housing markets will require citizens to force local governments to roll back the many regulations that prevent homeowners and developers from fully serving the needs of renters and would-be homebuyers.