Oblivious life-threateningly terrible cooks?
Usually the food is a gift from a girl to a boy - for example, sharing bentos at school or making the boy chocolate for valentines day. These are pretty common occurances in both games and anime - usually in the lead up to a confession of love. When guys give gifts to girls in anime it's more often jewellery or something to remember them by.

Gift-Giving going wrong is another trope and the humour in it is that the character getting the present feels obliged to pretend that they really like the gift. For example, getting a present that you already own. This trope has been going in different media for ages, and stems from real-life experiences. I know I've gotten presents I haven't been overly thrilled by but had to express my gratitude to be polite.

So, when gift-giving going wrong is applied to food - the character has to try and eat a disgusting meal while saying it's delicious - or at least, not say it's awful. The humour comes from the conflicted emotions and the effort the character has to put in to make sure it doesn't come across on his face that it's disgusting.

I think the fact that gifting food occurs so often in anime, means that this alternative gifting has become a spinoff as it were - and has become a trope in its own right. 

I'm not sure if this answers your question or not - add a comment if it doesn't :)