The camera lens projects an image of the outside world on the surface of the imaging chip inside and at the rear of the digital camera. The brightness of this projected image is important. Picture quality is dependent on adjusting this image brightness to a suitable level. If too bright, the resulting image will be over-exposed. If too dim the picture will be under-exposed. Optimum results are obtained when the image brightness is sport on. The aperture adjustment increases or decreases the working diameter of the lens. Because the lens acts like a funnel it is a gatherer of light, the greater the working diameter, the brighter the projected image.
Focal length is how we gage the ability of the lens to image. A moderate focal length produces an image that we call a “normal” view. A long lens acts like a telescope in that it magnifies like a telescope but at the price of reducing the width of the field-of-view. A short focal length yields tiny images of objects however the field-of-view covers a wide-angle.
Now the brightness of the image as projected by the lens is intertwined with focal length and aperture diameter. The longer the focal length, the more the image is magnified. This higher magnification forces the light that makes up the projected image to be spread thinner. In other words, a magnified image is dimmer than an image with lesser magnification.
As you zoom to higher and higher magnifications, it is necessary to somehow compensate for light loss. This is accomplished by causing the working diameter of the lens to perform as if it too were widening with the zoom. This is accomplished by causing the lens assembly ahead of the aperture to magnify the opening. This action allows the aperture to pass more and more light as the zoom increases the magnification. This is a delicate balancing act. We would prefer that the image brightness remain constant throughout the zoom but this can require complicated and expensive lens design. It is often the case that if a constant image brightness is the goal, the cost of the lens may become prohibited. Thus to keep the lens price reasonable, a constant image, price is sacrificed for affordability.
As to what subject distances are in focus and not, this falls under the subject called “depth-of-filed”. The span of distance that yields sharply focused images is a variable. The ingredients are:
Aperture diameter – small aperture diameters expand the zone of depth of field whereas large diameter apertures yield shallow zones of depth of field.
Short focal length lenses yield expanded depth of filed whereas long focal length lenses have a narrower zone of depth of field.
Distance to subject plays a key role. Close imaging yields shallow depth of field whereas focusing on objects that are far, yields expanded depth of filed.
These topics have a learning curve, you will not get a handle on this stuff until you study and then study some more