This is one question that comes up time and time again, and one that even some experts differ in opinion on.
Firstly, your sebaceous glands are responsible for secreting sebum, the natural oils that moisturise and waterproof your skin and hair. Each time you shampoo your hair, you strip it of these essential oils. This causes the body to produce additional sebum to replace that which has been washed out.
Frequently washing the hair can lead to the overproduction of sebum in order to compensate for its constant removal. This is why your hair may appear to be greasy the day after washing. The body knows that the oils are going to be washed out, and so they play catch up. Furthermore, washing your hair on a daily basis causes it to lose moisture and become dry and brittle.
Those who only wash their hair every two to three days have caused the body to produce sebum at a much slower pace, as the body knows that it will not be washed straight away. Hair that is washed less regularly will not get as greasy or oily as quick as hair that is washed on a daily basis.