As the light rays passing the lens tube and the diaphragm, some may be diffracted as shown in the figures below. If the diaphragm is large (i.e., a large aperture), because the proportion of the diffracted light and the non-diffracted light is so small and is negligible, diffraction does not contribute to the loss-of-quality very much. See the left figure below. However, when the diaphragm is small (i.e., a small aperture), the amount of light that can pass through the diaphragm is reduced and hence the proportion of the diffracted and non-diffracted light becomes significant. As a result, the quality of the image is also reduced. See the right figure below. Therefore, closing the diaphragm (i.e., using small apertures) all the way down to the smallest aperture may not increase the quality of an image. In general, the quality of a lens increases as diaphragm closes down. This improvement will reach certain point. After this, quality goes down because of the impact of diffraction.