This illusion works because Escher is exploiting the way our brains perceive perspective in order to create a visual paradox. Most artists use these rules of perspective to create realistic three dimensional images on a two-dimensional piece of paper, but Escher is manipulating these rules to create this famous illusion.
Despite the fact that this illusion has its origins in the exploitation of rules of perspective in drawing, it turns out that one can actually build such an object in the real world! A video is below the jump.
This seemingly impossible object is actually a result of perspective. The illusion only works when we view the object from this particular angle. If we move around the object, we can see that this seemingly impossible object is actually quite real:
Now this explains how the object is constructed, but it still doesn't explain how the water can be poured in such a way that it appears to flow uphill. In researching this online I couldn't find an explanation beyond the use of computer graphics. If anyone knows how this works, I would love to hear about it in comments.
However the illusion is accomplished, it reveals more important evidence that our visual systems construct an image of the world, rather than directly copying what we actually see. By exploiting this knowledge we can then create really interesting and provocative illusions. However, this knowledge can also be used to deceive and confuse people. As critical thinkers we need to be aware of this, so that we can avoid being deceived.