A series of AlGaAs/InGaAs/AlGaAs quantum-well heterostructures with different quantum-well depths and approximately the same concentrations of two-dimensional electrons is grown by molecular-beam epitaxy. The built-in electric field in the grown samples is determined from the photoreflectance data and, on this basis, the energy-band structure in the quantum-well region is calculated. It is found that the highest mobility μe of two-dimensional electrons is attained in the sample with a barrier-layer thickness of Lb = 11 nm. Measurements of the photoluminescence spectra and the band-structure calculations demonstrate that, as the quantum well becomes closer to the surface, the doping profile broadens due to diffusion and segregation processes. The nonmonotonic dependence of μe on the distance between the surface and the quantum well is explained.