The socioeconomic impact of a grocery store is far more important than anything happening in the SaaS world. Towns live and die by grocery stores-- food deserts as they're known in areas that go without. It's fair to be critical of a sector with tighter margins because food is rather low on Maslow's hierarchy of needs. SaaS is expendable, food isn't.
Do they? Or are things like food deserts transitive symptoms of deeper problems? E.g. that the surrounding area is poor and getting poorer. If so, no amount of legislation will change that
Programs like SNAP, the earned income tax credit, subsidized child-care, and refundable tax credits for children have an immediate impact. Legislation could also provide a universal basic income.
If that's too pink a set of approaches to reduce the impact of poverty for you, governments can also subsidize development of new housing and invest in infrastructure upgrades that draw folks with higher incomes into a community. This works best if you are in a metropolitan area. In rural communities, it's not uncommon to pour great sums of money into courting large employers, giving them land or tax free status for extended periods.
Hell, if your goal is just to get a grocery store, pour on enough subsidies and someone will show up to collect that money.
Place where I used to live shut down the main bus line in the poorest part of town. The result was people couldn't easily go to the local (small) market which then closed. The result was going from a 10 minute bus ride to almost an hour one way. The old line had quite a few stops along the way, so residents with a few bags of groceries didn't have far to walk. The new route had one stop which was placed far from the residence area.
It's incoherent to use the example of low service density as a justification to criticize a grocer for taking higher profits. You can't pursue both sides of a tradeoff simultaneously.
The more money there is to be made in the grocery sector, the more grocers there will be to compete for it, located in the places where the money flows. Likewise the leaner they have to operate, the more they'll shut down in marginal territory that can't support their business, and the more areas will go without convenient access.
If selling groceries in low-access areas for low profits is indicated by the necessity of food, then nobody is stopping you from doing it; but as the grandparent comment hinted, if you find your niche in high-margin software instead then you're following the money, just like grocers do.