Look at it this way. With a small enough aperture, you don't even need a lens! That is called a pinhole camera.

A lens focuses objects at a particular distance, because it works by bending light.

A pinhole (at least an ideal one) works by mapping points of light from different angles to corresponding angles on the film, irrespective of distance. (Real pinholes have limitations. Too small a pinhole will simply scatter light due to diffraction.) 

An aperture in front of a lens brings in some of the characteristics of the pinhole. The smaller you make the aperture, the more you effectively turn your camera into a pinhole camera. This brings in the advantage of wide depth-of-field focus, but also some of the disadvantages of the pinhole: less light gathering power, diffraction artifacts at very high f stop numbers.