There is a loss in sharpness due to diffraction at smaller apertures. Its a bit of a balancing act between depth of field and this loss of sharpness due to diffraction. That's why the sweet spot is somewhere like 5.6 or 8 (35 mm).