Recent estimates of the Hubble constant indicate a discrepancy between the age of the Universe and the ages of the oldest stars. This problem can be solved by introducing a cosmological constant Lambda into Einstein's theory of gravity. However, the value required is about 10(121) times smaller than the 'natural' value set by the Planck scale. Such a small value, corresponding to an energy of similar to 0.003 eV, seems unlikely to emerge from theories of particle physics. Thus some authors have argued that quantum gravity requires Lambda to be precisely zero. Another possibility is that the small value of Lambda is determined by the anthropic principle, i.e. by the requirement that an acceptable Universe allows stars and observers to form. We investigate this possibility in this Letter, and show that it might account for a value close to that suggested by observations.