SANTA MARIA, Calif.—Oscar Oswalvo Loera wakes up before dawn each day to pick lettuce, strawberries and other produce in the fertile fields surrounding this farm town.

The home he walks out of is a former Econo Lodge, which used to cater to Highway 101 budget travelers. Now it sits at the intersection of two of California’s deepest and most polarizing issues: immigration and the lack of affordable housing.

Motels,...