When you're sad, friends cheer you up.

Literal

Sad time [topic-は] friends [subject-が] encourage [for you-てくれる].

~てくれる frames the friends' encouragement as a favor received by the speaker. 励ましてくれる means 'encourage (for my benefit).' A warm sentence about friendship.