When light enters your eye, it hits photoreceptors called rod and cone cells on your retina which contain light sensitive pigments (rhodopsin and iodopsin) that break down when exposed to light. When this happens it create an impulse to the sensory areas of the brain allowing you to see.
When you press on your eyeball, the pressure has basically the same effect as light and breaks down the pigment to send impulses to the brain as if it were light.