Literally, iets van die kos is something of the food.
In natural English, it means some of the food or any of the food.
So:
In this sentence, the whole phrase means some of the food left over.
English often uses any in this kind of conditional sentence:
Afrikaans uses iets very naturally here.
That is because the sentence begins with a fronted subordinate clause:
As daar iets van die kos oor is, ...
After that, Afrikaans keeps the main clause in verb-second position. Since the whole As ... clause takes the first slot, the finite verb of the main clause comes next:
If you wrote the main clause by itself, it would be:
So the order changes because the if-clause comes first.
Dit means it, and it refers back to the leftover food.
So:
Afrikaans often puts a short direct-object pronoun like dit before the vir phrase:
So gee my ouma dit vir my neef means my grandmother gives it to my cousin.
Here vir does not mean for in the English sense. It marks the recipient, so it is closer to to in English.
This is very common with verbs like gee.
So in this sentence:
A useful way to think of it is:
This is an infinitive construction.
In this sentence it shows purpose:
So om ... te often corresponds to English to or in order to.
A few examples:
Saam means something like along or with you.
So:
In this sentence, saam te neem gives the idea of carrying the food away with him, not just taking it in some abstract sense.
English often leaves this idea unspoken, but Afrikaans uses saam very naturally:
My ouma gee dit vir my neef om huis toe saam te neem as daar iets van die kos oor is.
That still means the same thing.
But putting the As ... clause first is very natural when the speaker wants to set up the condition first:
So the original word order is completely normal and probably the most natural version in context.