What's the difference when using やる and あげる with the て-form of a verb. For example: 教えてやる and 教えてあげる.
The difference is that やる is only used with animals or very, very young children, as it sounds very patronising, as though the person you are doing a favor to is way lower than your level socially speaking. So basically, if you ~てやる someone, you are treating them like an animal (bad idea).
Take into account that even あげる itself can sound patronising, so it should be used only with people at the same social level than you (e. g. a friend) or lower (e. g. one of your employees).
太郎【たろう】くんにギターを弾くのを教えてあげた。 I taught Tarou to play the guitar.
私の犬にちゃんと座【すわ】るのを教えてやった。I taught my dog to sit properly.
Grammatically, they convey the same idea: to perform an action in someone's favor or for the sake of someone.