While I would point to the excellent book of Raph Koster "A theory of fun", I will try to point the basics that I remember of it. There is also a few nice pdfs online if anyone is interested.
According to this pdf at least, Raph defines fun as "the emotional response to learning". He talks about the positive emotional response though and he goes on to talk about patterns and how our mind recognizes, categorizes and eventually uses which eventually leads to learning.
There is a lot of pattern recognition and use as you build an engine so part of the fun comes from there. Then still according to what I remember from the book just collecting things gives to many many people pleasant emotions, as it is in our genes from the very old humans that used to collect fruits and other things from trees and simply those that found it pleasant were more succesful in it and passed their genes to the next generations.
Finally and still according to what i remember from the book there is also another big thing that gives us pleasant emotions from playing an engine and this is achieving and exhibiting mastery. We make something that is not easy at least in our eyes and probably to the eyes of our peers and we do it well and we eventually feel good from all this and we tend to do it over and over again to get this feeling of pleasantry.
I am sorry for my bad english or if the text is not very easy to understand, but if I am to make the above text more readable, I will have to spend a substantial amount of time to do so.
Hope it helps.
Here are the really nice links - pdf's
Excertion from the book
http://vk.com/doc-55569780_205361293Quick powerpoint presentation that I do not remember what it includes
http://www.theoryoffun.com/theoryoffun.pdfA cool pdf that I just found it exists and is named a theory of fun 10 years later.
http://www.raphkoster.com/gaming/gdco12/Koster_Raph_Theory_Fun_10.pdf