MARICOPA, Ariz.—After Arizona passed a series of tough anti-immigration laws, Rob Knorr couldn’t find enough Mexican field hands to pick his jalapeño peppers. He sharply reduced his acreage and invested $2 million developing a machine to remove pepper stems. His goal was to cut the number of laborers he needed by 90% and to hire higher-paid U.S. machinists instead.

“We used to have many migrant families. They aren’t coming back,” says Mr. Knorr, who owns RK Farms LLC, an hour’s drive from Phoenix.

...