Minimum Wage
The ditch is to accommodate conduit for underground power lines. In the US of A, this work would be done with four guys and a backhoe. Apparently the city likes to provide employment for as many of its citizens as possible, so they're doing the digging by hand. Besides, there's the possibility that the city's backhoe is being used for other purposes; say, digging irrigation ditches at someone's hacienda—someone with juice.
OK. That was cynical. We've made great strides fighting corruption. I'm confident that such abuses are almost a thing of the past.

So how much are these guys being paid? By law, the minimum wage is around $50 pesos per day ($4.50 US), but it's unlikely anybody works for that. You certainly couldn't live on so little, even if your family had several wage earners.
The workers in the photo are probably being paid $130-$150 pesos per day ($12-$14 US). You can't live on that either, but these are among the highest-paid laborers in Mexico. By contrast, the minimum wage in the US is almost $47 for an eight-hour day, more than ten times that of Mexico. Nobody works for that either; at least not in California, where the state-mandated eight-hour minimum wage is $60, and especially not in San Francisco, where it's $76.
I find it hard to imagine that any fence could deter migration to the north, given that huge pay differential.
If nobody in Mexico works at the minimum wage, why does the government legislate it? Well, certain taxes are based on the minimum wage, which is increased every year for inflation. That way, when the minimum wage goes up, the social security tax goes up automatically.
But of course, there's a loophole. For example, you may pay your laborer $150 pesos per day, but when you pay social security taxes, you'll claim you're paying him the minimum wage, $50 pesos. Unless you're really honest. Or really stupid. Everybody knows you're not paying minimum wage, but everybody goes along with the fiction that you are. So your actual social security tax payments are only a third of what the law says they should be.
It gets better. Policymakers know full well what's going on, so they set the social security tax rate to account for the cheating. That way, there's enough money to fund the social security system, keeping the administrators happy, and everybody else figures they're getting away with something, making them happy.
The minimum wage affects fines: for traffic violations, building code violations, urinating in public, whatever. Fines are figured in salarios minimos (minimum daily salaries). A friend was fined approximately six salarios minimos for failing to wear her seat belt. Another fine, for speeding, was a whopping 20 salarios minimos —$952 pesos.
You probably see that something something is seriously wrong here. How could even relatively high-paid workers afford to pay a speeding ticket?
The answer is they can't. Utterly can't. Not a chance. So they offer the cop a bribe. The cop doesn't solicit the bribe; he doesn't have to ask. The stupid fine system does the asking for him. So from time to time we are treated to the sight of a State cop standing beside his highyway cruiser emblazoned with the words "No más mordida" (no more bribery), pocketing a proffered $100 peso note. Solo dos salarios minimos.