Your food has to reach "Food Defect Action Levels" that have been created by the FDA before the regulator will take action against products with foreign matter. In other words, there is a level of grossness food has to get to before they do anything about it.
Simply put, there has to be a certain amount of bugs or bug parts in your food before it's deemed unsafe, but a little bit is totally fine. For example, manufacturers can't allow more than 225 bug parts in 225 grams of pasta. Any less than 225 parts in that batch is ok for the FDA.
Most of the time, this does not mean these foods are unsafe and in order to be on the list of these foods, the "defects" (what the FDA calls bugs and rodents) have to have been found to cause no health hazards.
Realistically it's impossible to eliminate all bugs from food grown outdoors, no matter how small the manufacturer -- but there is a certain ick-factor involved with the idea that there could be maggots in your food in any amount or form.