Grocers offset some of this risk by processing some of the food onsite, selling precooked meals, premade salads, etc.
If it was more profitable to further reduce costs, then they would, but there are diminishing returns on end of the line food processing, since the kitchens and packaging required are generalized for a broad range of foods instead of being a specialized operation that is more efficient.
It sucks, but it's the system that capital built, and pretty much the only thing we can do if we don't like it is to focus on buying local, or electing politicians who will target food waste as a policy.
Fresh food spoils. Always has. Happens less now with readily available refrigeration, salt, and fast long-distance logistics. Those supply chain improvements make it more feasible to produce a lot of it and have a wide variety available almost without regard to season.
Ever since people farmed, they put in all the labor and got out only the portion of product that they could use without spoiling. That's how we got canning, bread, cheese, beer/wine, and other means to preserve the caloric content of agricultural products.
If the goal is to be pedantic, then technically the "biological reason" is that nature gave humans the ability to alter their environment in ways that allows the north eastern United States to eat fresh oranges and pineapples in December.
If you're just gonna throw em out I'll take a whole sack of potatoes and put them to use.