Why is the diaphragm to control the amount of light entering the camera typically in the lens and not the camera body itself?
Most lenses have one or more lens elements behind the diaphragm also. I actually haven't seen one that doesn't.
The diaphragm is not at the back of the lens but in between optical elements.
Forcing it to be at the back would be severely restrictive in terms of lens design and wide-angle lenses would become impossible on most a sensor-size and flange distance combinations.
Simple reason - it performs better when placed inside the lens. Interestingly the shutter assembly can also be made to perform better when placed inside the lens. So called leaf shutters operate when the cone of light passing through the lens is at its narrowest. This limits the travel required, allowing the shutter to go from completely open to completely closed far faster than a shutter inside the camera, allowing significantly faster sync speeds (maximum shutter speed with flash).
So why don't all lenses contain leaf shutters in addition to irises? Increased cost is one factor, unlike the case for an integral lens iris, a leaf shutter would have no effect on image quality so the cost is harder to justify. Secondly there's the fact that a focal plane shutter can achieve shorter exposure times than a leaf shutter by beginning to close before fully open (at the expense of no longer being able to sync with a flashgun).
The diaphragm performs two different functions:
- It limits the amount of light that passes through the lens
- It modifies the depth-of-focus
The second function can only be accomplished by placing the diaphragm at a particular point in the light path (at the focal point of one of the lens elements). That place is essentially always inside the lens body.
If you put the diaphragm on the camera body, you'd be limited to essentially the wide-open focus depth, and you might have some weird vignette-style effects from imaging the aperture onto the focal plane.
Actually, in-body apertures have existed on interchangeable-lens cameras, and in a way that allows lenses of different focal lengths to have common maximum apertures. Perhaps the best-known camera to do this was the Pentax Auto 110, a 110-format film SLR. Pentax went that route with the Auto 110 because it would be sturdier and less complex than trying to fit an iris and the auto-aperture linkage into the tiny lenses for the system.
The main problem with that approach is that it severely restricts the optical design of the lenses that may be used with the camera, since the node point of the lens (the point at which you can controllably restrict the amount of light passing through the lens without vignetting the image) needs to lie behind the physical lens. When that can be arranged, an iris that is external to the lens will have the same effects on exposure and depth of field as a more conventional design.
That means that retrofocus lens designs are impossible since the iris has to interact with the wide-angle group of elements and not the rear telephoto group, and that limits how wide the lenses can be. It also means that any long lenses need to be true telephoto designs (that is, the lens has to be optically shorter at the film side than it is overall) with a rear geometry that looks the same as the widest lens used. When your widest wide-angle option isn't so very wide, your longest long lens can't be too very long, and your mid-range lenses may not be optimal designs because you can't just put the iris where it "wants" to be, you lose a lot of options. And since the main draw of interchangeable lens cameras is being able to use the best lens for a particular task, cutting the choices down to three or four possible lenses over a narrow range of focal lengths would be a pretty effective foot bullet. Unless, of course, you're making cameras in a niche where it makes a sort of sense, like the Auto 110.