It's cheaper to throw it away than deal with the logistics necessary to give it away.
Problem is, there's a Good Samaritan food giveaway law that covers this.
From the USDA website;
"In order to receive protections under the act, a person or gleaner must donate in good faith apparently wholesome food or apparently fit grocery products to a non-profit organization for ultimate distribution to needy individuals or families. It does not cover direct donations to needy individuals or families."
So first off, anyone who cares to can sue on the basis it wasn't donated in good faith, or over whatever the hell "apparently" means (and I've heard some junk) which the defendant will then have to prove false. Even if it's tossed out, that's more man hours wasted, more money spent, more bad press, all of which contributes to the food distributor eventually getting shut down outright.
Then, all donated food must be funneled through someone else, which limits distribution because there are many more food distributors than government approved non profit locations.
This then further limits how much food can be given away because A) A government approved food charity has to follow more rules for who is and is not allowed to receive food, and B) A lot of the food that can be theoretically distributed isn't because with all the aforementioned food can't be legally pushed out fast enough.
And anybody who donates directly is fucked up creek without a paddle.
Source - I volunteer at a govt approved food charity, do you have any idea how much food goes straight up rotten because we can't legally distribute it fast enough?
Hundreds of pounds per month, if we're lucky.
And that's just us, at one location.
Oh, and let me make it worse for you - we get fresh produce shipped in, stock overflow from farmers and such. A good chunk of that goes bad before it even reaches the distributor because legal restrictions combine with logistics to leave it sitting for weeks and months before we can open it up and get rid of it.
It's our "have fun with the newbies" ritual where one of the experienced crew sits them down for two, three, four hours scraping out the rotten vegetables from the good, then letting the "good" sit in good conditions for a day or so before checking them again to make sure they didn't get mouldy or whatever somewhere we didn't see the first time.
If we don't just toss the whole bag because the reek is strong enough to write it off.
So yeah nah, the law is responsible for destroying a fair bit of food before it can be given to the hungry, profit or no profit.