For entertainment, at the simplest level. Games are a way to spend time enjoyably and to switch off from everything else for a while.
There is more to it than that, of course. They offer challenge, a sense of progress, and a reason to spend time with other people, which is why the medium has ended up covering everything from a two-minute puzzle to a hundred-hour story.