It is interesting to look up the definition of something so fundamental to our lives and wonder about its veracity. There's lots of research into fun and laughter, but none of it is definite. I don't assume any wonderful new and accurate viewpoint on the issue, but from that which I have read on the subject, I make a hypothesis of fun for the controlled problem domain of games.
Fun can be attributed to self growth, or the growth of your self form immersed into a virtual world (this is similar to feeling proud that your kid just scored a home run).
Growth of self when playing games is a feeling of mastery over the game (shoot-em-ups, racing games or fighting games are good examples of this kind of growth).
You can feel growth from your virtual self only when the game permits growth, and therefore most RPGs fall into the avatar growth category.
Fun can also be attributed to a release of pain, or awareness of a redirection of pain.
You can have fun by achieving goals set that hinder your advancement in the virtual world (again RPGs do this, and most modern shooters set up tasks for you to get through to add fun).
You can have fun by managing to get the impending doom switched over to your opponent (think of strategy games in this one, they are fun because you have to swing the "I am winning" over to your team)
This leads to a simple understanding of why certain games seem more fun than others. The complexity comes in when you start to understand how many ways in which this has been chopped up, mixed up, and used to reinvent the games we play today.