I know this question is more than two months old already, but since I’m Norwegian, I’d figure I’d give my simple non-professional take on it:
It’s basically the difference between doing something FOR someone, and giving something TO (“til”) someone. In Norwegian, gifts and anything else you give someone uses “til”. Just as you would say
I gave the keys to John = Jeg ga nøklene til John
you keep that preposition in a sentence like this:
That gift/present is for John = Den gaven/presangen er til John
We would use “for” if it’s an action instead, like a favour, for instance. So the difference between:
Jeg kjøpte den til deg
Jeg kjøpte den for deg
is that is the first sentence means “I bought it for you” (as in a gift), while the second sentence basically means that I bought it for you as a favour. “You could have bought it yourself, but I’d figure I’d buy it FOR you, so you don’t need to buy it yourself”. In other words, the focus is on the act of buying, instead of the thing you are giving. (Slightly forced example, since the first sentence could still be used in the second meaning, if it’s obvious from the situation.)
So in your first example, the opening of the door is an action being done FOR (“for”) the guests, while in the other, the presents are things that are meant to be given TO (“til”) the children.
Jeg støvsugde leiligheten for deg = I vacuumed the apartment for you (act/favour) (lit. “dust-sucked”)
Jeg har laget mat til deg = I’ve made food for you (still an action of sorts, but the focus is on the food (a thing) and that this food is for you)
Jeg har laget mat til bestefar for deg = I’ve made food for grandpa for you
The food/thing is for grandpa (“til”), but I did you a favour (action) and made it so that you don’t have to (“for”).
I can see how it’s confusing if you’re used to “for” in both cases. I often find prepositions in languages I’m trying to learn to be some of the most confusing things.