Entertainment, primarily — that's what they're built for.
Beyond that, there's a reasonable body of evidence that games can improve hand-eye coordination, along with pattern recognition, spatial reasoning and problem-solving, depending on the genre. Puzzle and strategy games in particular tend to exercise planning skills.
None of that makes them a substitute for other activities, but "just for fun" undersells them a little.