@Pigeoninthehouse
There's probably more care and attention to hygiene given when cooking for people you care about than the average food worker.
Its real people preparing the food your buy in, people that are probably earning minimum wage, working long shifts when feeling ill and tired, because they can't afford not to work. Not sure why that is preferable to someone making something at home.
As has been said though, if you get food poisoning from a restaurant, you can simply not go there again. Or if you dislike the food or it's undercooked, you can complain, send it back, ask for a refund or swap your meal for something else. There's no personal relationship there so it's much easier to speak up and say "this is not nice, can I have X instead please".
But if a friend makes you something, you can't very well say to their face "sorry but that looks horrendous" or ask to swap it for a different gift, so social etiquette requires you to be polite and say thank you, even if you know you won't actually enjoy it or eat it.
And if you do eat it and it makes you sick, or you really dislike it, or it's undercooked, you're unlikely to tell your friend that, and you're then also put in an awkward position if they make it again - you don't want to risk getting sick (again), you can't return it or re-gift it, so there's no other option but to put it in the bin.