The role of stochasticity on gene expression is widely discussed. Both potential advantages and disadvantages have been revealed. In some systems, noise in gene expression has been quantified, in among others the lac operon of Escherichia coli. Whether stochastic gene expression in this system is detrimental or beneficial for the cells is, however, still unclear. We are interested in the effects of stochasticity from an evolutionary point of view. We study this question in the lac operon, taking a computational approach: using a detailed, quantitative, spatial model, we evolve through a mutation-selection process the shape of the promoter function and therewith the effective amount of stochasticity. We find that noise values for lactose, the natural inducer, are much lower than for artificial, nonmetabolizable inducers, because these artificial inducers experience a stronger positive feedback. In the evolved promoter functions, noise due to stochasticity in gene expression, when induced by lactose, only plays a very minor role in short-term physiological adaptation, because other sources of population heterogeneity dominate. Finally, promoter functions evolved in the stochastic model evolve to higher repressed transcription rates than those evolved in a deterministic version of the model. This causes these promoter functions to experience less stochasticity in gene expression. We show that a high repression rate and hence high stochasticity increases the delay in lactose uptake in a variable environment. We conclude that the lac operon evolved such that the impact of stochastic gene expression is minor in its natural environment, but happens to respond with much stronger stochasticity when confronted with artificial inducers. In this particular system, we have shown that stochasticity is detrimental. Moreover, we demonstrate that in silico evolution in a quantitative model, by mutating the parameters of interest, is a promising way to unravel the functional properties of biological systems.