This post was originally a comment to http://cristianmihai.net/2012/10/16/beautiful/#comment-14964.
I believe that our perception and cognition are processes that cannot be completely described by algorithms. They are creative and that means that they can always extend into something new. Any description of them in terms of algorithms or formal theories can be broken. If we perceive something and there is nothing new in it, the perception is boring. If we successfully extend our cognitive structures to perceive something that was not covered by our previous knowledge, we have an aesthetic experience. The feeling of beauty, I suppose, is a feeling of successful extension of our perceptive knowledge. If what we perceive is too simple, we assimilate it without creating something new. Then it is boring. If it is too complex, we don’t manage to assimilate it, and also do not have that “sense of achievement” of our perceptive system. If, however, we manage to successfully integrate the new into our existing perceptive knowledge, we are rewarded with this special emotion of beauty. So beauty may be seen as a side effect of very basic functions of our learning perceptive system. It is due to the creative nature of our cognition.
The best works of art are so rich that they can produce such experiences over and over again. And the feeling of beauty marks a moment of growth of ourselves, so yes, we gain something when we experience beauty.