Part of it is preservatives. The other part is the food being made (that is, before it arrives at the store) in conditions where things are kept scrupulously clean wherever possible. (I've worked in a bake-factory before - it was something else! And while it did get messy, I would hazard to say most of those messes were actually edible still.)
Also there's the cooking itself in the restaurant. I've worked in McDonalds before, and if the crew is reasonably competent then I'll eat there anytime I need a quick bite. They work with absurdly wide margins on their food safety (wider than they really need to be) mainly to assure the food tastes good rather than is simply safe to eat. Trust me, McDonalds food tastes its best when management is scrupulously enforcing their 'food safety guidelines'. Will those beef patties still be safe to eat an hour from now rather than the twenty minute hold time in the warmer that is prescribed? Sure. They'll be a bit dry, but they'll certainly be safe to eat.
Also there's the cooking itself in the restaurant. I've worked in McDonalds before, and if the crew is reasonably competent then I'll eat there anytime I need a quick bite. They work with absurdly wide margins on their food safety (wider than they really need to be) mainly to assure the food tastes good rather than is simply safe to eat. Trust me, McDonalds food tastes its best when management is scrupulously enforcing their 'food safety guidelines'. Will those beef patties still be safe to eat an hour from now rather than the twenty minute hold time in the warmer that is prescribed? Sure. They'll be a bit dry, but they'll certainly be safe to eat.