“Exposure” is the act of exposing the image sensor to light. By adjusting the amount of light, you can make a photograph of a bright sunlit scene look dark, or a shot of a dark interior look bright. DSLR Cameras have auto-exposure systems that automatically produce photographs of optimal brightness. You can use this system for optimal results with both brightly-lit and poorly-lit subjects. This is referred to as “optimal exposure.”
Exposure compensation is used to alter exposure from the value selected by the camera, making photographs brighter or darker.
In modes P, S, and A, the camera automatically adjusts settings for optimal exposure, but this may not always produce the exposure the photographer intended. Exposure is a matter of personal preference, and an exposure brighter or darker than that selected by the camera may sometimes better reflect the photographer's intent. The feature used in such situations is called exposure compensation. DSLR Cameras allow you to check the results immediately, so you can take a photograph, display it in the monitor, and then raise exposure compensation for brighter results or lower exposure compensation for darker results and take another picture.
A dark, backlit subject
The same subject brightened with positive exposure compensation
In concrete terms, leaving the camera in charge of exposure produces optimal results with a variety of scenes. Photographers, however, may feel that brighter results would be better for some photographs and that darker results would be better for others, meaning that they may not necessarily find that the optimal exposure selected by the auto-exposure system is suitable for all photographs.
Nikon (2019) DSLR Camera Basics. Retrieved from https://imaging.nikon.com/lineup/dslr/basics/01/01.htm