The aperture is the main determinant of potential lens resolution. I use potential because the imperfections in lens design and manufacture will also strongly affect the actual resolution of the lens. So, assuming a perfect lens, the aperture is the main determinant of resolution in most imaging situations.
The relative size of the aperture in relation to the detector determines the size of the Airy disc. This encompasses two quantities: 1) The size of the aperture and 2) The distance that the aperture is from the detector. A large aperture that is close to the detector will produce the highest potential resolution.
The easiest way for me to think about the relative size of the aperture is in terms of the angle that the aperture makes with the detector. A large aperture that is close to the detector will allow light from a larger number of incident angles to hit the detector. That same aperture farther away will lessen that variety of angles.
The angle that the aperture makes with the detector determines the amount of diffraction. A large angle will produce less diffraction and a small angle will produce more. More diffraction means a larger Airy disc.
The realtive size of the aperture can be expressed as the effective aperture. The aperture setting on a lens is only applicable to infinity focus. That means an f/8 aperture focusing at the focal length of the lens. Two f/8 lenses will have the same amount of diffraction at inifnity focus regardless of the focal length since the calculation of f/number already compensates for different distance from the aperture to the detector.
As the lens is focused closer than infinity, the aperture will move away from the detector. This increased distance will lessen the angle that the aperture makes with the detector and will thus increase the diffraction and the size of the Airy disc. The distance that the aperture is from the detector will be m+1.
The relative size of the aperture can be expressed as the effective aperture. The effective aperture can be expressed as :
N' = N*(m+1) (where N' is the effective aperture, N is the actual aperture setting, m is the magnification)
An f/8 lens will have an effective aperture of f/16 when working at 1:1 magnification. The effective aperture is the most important determinant of diffraction and thus the resolution that the lens is producing at the detector. That means that as the magnification increases, the effective aperture also increases. An effective aperture of f/16 at 1:1 will produce the same amount of diffraction as a real aperture of f/16 at infinity focus.
The astute out there might say "Hey, since the effective aperture increases as the magnification increases I shouldn't get any more resolution out of a lens as I increase the magnification." This is where the (m+1) factor comes into play. At low magnification the "+1" makes a larger difference in the effective aperture than it does at high magnification.
As an example: If I am working at 1:1 and f/8, my EA (effective aperture) is 16. At 2:1 my effective aperture 24. The magnification has doubled, but my effective aperture has only risen by 50%. that means that I will get more detail out of the image at 2:1 than 1:1. This effect lessens as the magnification rises and eventually you won't get signficant increased resolution out of a lens by increasing the magnification and is commonly called empty magnification.
As the magnification rises, the only effective way to get increased image resolution is to make the aperture larger, thus decreasing the effective aperture. That means opening up the aperture. The problem lies in the fact that the lens aberrations will increase as the aperture is opened and will tend to negate any improvement and even worsen the image beyond a certain aperture setting.
This trade-off between aperture size (diffraction)and aberrations means that a lens will have a sweet spot for resolution and have a sharpest aperture. Most commercial lenses will be sharpest in the f/5.6 to f/8 range. Lenses with larger sharpest apertures tend to be specialty macro lenses (shorter focal length bellows lenses) and microscope objectives.
Next: It's not really the aperture, it's the exit pupil.