She bought him a sweater.

Literal

She [topic-は] he [for-に] sweater [object-を] [bought-for-him-買ってやった].

~てやる attaches the rougher 'give' auxiliary やる onto a verb to mean 'do for someone (downward).' Here the action 買う ('buy') is performed for 彼's benefit — the beneficiary is marked with に. As with bare やる, ~てやる has a slightly blunt or familiar tone; ~てあげる is the polite default.