What is the difference between RAW and JPEG files? Lol
Well that's starting at the beginning.
A raw file is the unprocessed digital data from your camera's sensor. The sensor is light sensitive and generates a charge in response to exposure to light. It's a solar collector; light (photons) in electrons out. The charge is proportional to the exposure within the sensor's functional range. The sensor is monochrome. In order to "see" color we place a grid of filters over the sensor's pixels -- red, green and blue filters. That way we know that the charge from a pixel is either from a red filtered or green filtered or blue filtered pixel. Software embedded on a chip in your camera we call the ADC (analog to digital converter) takes the electron charges from the sensor and converts them to numbers and stores those numbers. So then we have for every pixel either a red value, green value or blue value. That's your raw data and your camera can save that raw data to the camera storage card.
The raw data is and must be created for every photo you take. But as raw data it doesn't look like much and isn't a usable photo. So your camera then processes that raw data in software that is called the camera's image processor. Different camera companies fuss over their image processing software and give it names. Nikon's is their EXPEED processor and Canon's is their DIGIC processor and etc. The image processor is responsive to the photographer who can control it via menu selections on the camera. She/he can choose color variations and noise filtering and sharpening and etc. etc. to influence the processing job the camera does. The result then is an RGB image that the camera typically saves as a JPEG file.
JPEG images are structurally different than raw data files. The pixels in the raw data file record either a red, green or blue value. The full color of the image has to be extrapolated from those three single color values. The pixels in a JPEG image each contain a red and green and blue value that mix together to make a wide range of colors so that a pixel can be orange or peach or burgundy or one of millions of colors.
JPEG files are compressed. This is real good because once compressed they are small and small is very good given bandwidth and storage space is limited. Unfortunately the compression used with JPEG files succeeds by discarding data. It's done very smartly and effectively and you'll be hard pressed to see the result but it makes further editing of the JPEG problematic.
JPEG images created from the raw data are processed images with emphasis on the word processed. The best analogy is cooking. Once the cake is baked it ain't easy to change it from chocolate to strawberry. You can't really unbake a cake. So once the raw data is processed into the camera's JPEG image you're substantially committed. A lot of photographers edit JPEGs to improve them but you're limited in what you can do. If data in the raw file was discarded while processing the JPEG you're not going to have access to that data while editing the JPEG.
If you want the best cake ever then you want a good cook. The software in the cameras that processes the raw data and creates the JPEGs doesn't get any cooking awards.
If you have the raw data you can process it yourself. You need software and skill. The potential is there to do a better job than the camera software but you need a good cook -- you'll have to learn. What you get is better image quality as well as exactly the cake you want with no compromises. I'm an excellent cook. I can always produce a better image from the raw data than the image the camera software generates or that can be created by trying to fix what the camera software generated. So that's a bottom line: Hand process raw data for superior IQ results.
The image processors of the various cameras have controls accessible to the photographer but they are limited. The engineers who designed that software had to target a generic average for the processor's output. It targets the middle of the bell curve with adjustments that permit you to push a standard deviation to either side. They can only do so much and as a result that software forces you to target your photographs to the same middle of the bell curve if you expect to get a usable JPEG. You can get pretty good average results of average scenes. If however you learn to expose optimally for the raw data and can hand process that data you can take photos that are simply beyond the average capacity of the camera's processor. Another reason I choose to save and process raw files. I take photos that can't be taken at all if relying on the camera's image processor.