Why does aperture size affect depth of field in photography?
The effect, aperture give to the depth of field is caused by the "used part of the lens".
As the a system of lenses can only make a certain point being focused, there is the need of a trick to gain a high depth of field. This is (not only but also) done by the small aperture.
The reduction of the used part of the lens leads to less aberrations for the not perfect focused light paths. You see the Parts (1) and (3) in the image being mapped better focused on the "photo plate" (5). The light paths from (2) are unaffected, because these are perfect focused. As you use a smaller part of the lens, your image will become more dark as is illustrated in the darker background of the "photo plate" on the right.
Source of image: https://en.wikipedia.org/wiki/File:Depth_of_field_illustration.svg
If you want an intuitive answer, the depth of field indicates the interval of distances in which the image will be approximately on focus. When you reduce the aperture, the light cone narrows. This means that you would observe that the confusion circles are smaller. Hence, the range of distances where the image is on focus has increased.
A formula for the far-field case (large distances) would be:
$\mathbf{DoF}=\frac{2Hs}{H^2-s^2}$
Where $H$ is the hyperfocal distance: $H=\frac{f}{\#fd}$, $f$ is the focal distance, $\#f$ the f number and $d$ is the size of the circle of confusion.