This is a really interesting question, mainly because I didn't immediately know the answer and hence had to go away and think about it ! When that failed, I called a friend who is a consultant opthalmologist to ask his opinion !
These lights are a so-called endoptic phenomenon. In other words, they originate from within the eye itself. The most likely explanation for the 'lights' or sparkles that you see when you rub your eyes is temporary interruption of the blood flow into the eye.
The patterns produced are very similar to those that you see when you stand up too quickly from a hot bath, or if you jump out of bed too fast. In these instances a 'postural drop' in blood pressure temporarily leads to reduced retinal perfusion and consequent inappropriate retinal activity, producing strange light patterns.
The retina has the highest metabolic rate of any tissue in the body and hence is the most energy and oxygen-hungry. Any interruption to its blood flow therefore causes rapid symptoms.
When you rub your eyes you are applying pressure directly onto the eyeball, raising the intraocular pressure. This can affect blood flow through intra-optic capillaries feeding the choroid (the network of blood vessels at the back of the eye that feed the retina), temporarily dimishing the supply to certain parts of the retina. According to my opthamology colleague, when performing eye surgery (and hence watching the retinal vessels beneath an operating microscope) it is frequently possible to cut off blood flow through the retinal artery, just by pressing on the eye.
It's also possible that some of the effect is down to sheer stress applied to the photoreceptors, but the blood flow model seems much more plausible.
To address Les's second question, regarding whether blind people experience the same phenomenon, as I have mentioned above, this is an endoptic effect (generated within the eyeball). Therefore, anyone who is blind due to a brain lesion, or a damaged optic nerve, would not be expected to experience this effect. Someone with retinal destruction similarly would not be expected to experience the effect.
Blind people do 'see' under certain circumstances, however. 'Blind sight', when patients perform much better on visual tasks than could be expected by chance alone, and despite claiming not to be able to see what they are doing, occurs when the primary visual part of the brain is damaged, but the eyes and other brain visual processing areas remain intact. Although the visual message fails to get through to the patients consciousness, it nonetheless is made available to other brain areas that can use the information - such as the motor system enabling patients to unwittingly avoid obstacles.
Another example of blind people seeing is when they dream, although this phenomenon is restricted to individuals who have gone blind after a period of being able to see. When we dream the regions of the brain that are concerned with consciously experiencing different senses we are awake - sight, hearing, touch and so on - switch on to create dreams. As one blind man said to me "I love going to sleep because I can see again. It's also especially useful in helping to remember what colours look like".
"I never forget a face, but in your case I'll make an exception"
- Groucho Marx