There are many resources on the web which explain nicely as to what RAW is and its advantages. RAW File captures what the sensor saw essentially. JPEG on the other hand is a derivative which has applied a lot of assumptions in an un-changeable way (for example White Balance).
Here is what Michael Reichmann of Luminous Landscape writes in This Link
. Reasons to Shoot Raw
— A raw file is comparable to the latent image contained in an exposed but undeveloped piece of film. It holds exactly what the imaging chip recorded. Nothing more. Nothing less. This means that the photographer is able to extract the maximum possible image quality, whether now or in the future. A good analogy with the traditional world of film is that you have the opportunity to use a different type of developer or development time at any point in the future if one comes along that you think might do a better job of processing the image.
— Raw files have not had while balance set. They are tagged with whatever the camera's setting was, (either that which was manually set or via auto-white-balance), but the actual data has not been changed. This allows one to set any colour temperature and white balance one wishes after the fact with no image degradation. It should be understood that once the file has been converted from the linear space and has had a gamma curve applied (such as in a JPG) white balance can no longer be properly done.
— File linearization and colour filter array (Bayer) conversion is done on a computer with a fast and powerful microprocessor. This allows much more sophisticated algorithms to be used than those done in a camera with its slower and less powerful processor and with less space for complex conversion programs.
— The raw file is tagged with contrast and saturation information as set in the camera by the user, but the actual image data has not been changed. The user is free to set these based on a per-image evaluation rather than use one or two generalized settings for all images taken.
— Possibly the biggest advantage of shooting raw is that one has a 16 bit image (post raw conversion) to work with. This means that the file has 65,536 levels to work with. This is opposed to a JPG file's 8 bit space with just 256 brightness levels available. This is important when editing an image, particularly if one is trying to open up shadows or alter brightness in any significant way.
Figures #1 and #2 below shows why. Assuming for this example a 5 stop dynamic range, you can see how much data is found in each of the brightness levels in the image. In other words with a 12 bit file the two darkest levels of the file combined have some 384 brightness levels to work with.
An 8 bit JPG file on the other hand has considerably less. Both the sRGB and Adobe RGB colour spaces use a gamma 2.2 encoding. Gamma encoding reallocates encoding levels from the upper f-stops into the lower f-stops to compensate for the human eye's greater sensitivity to absolute changes in the darker tone range. Therefore an 8 bit JPG file has just 47 brightness levels available in the bottom two stops. (The remaining levels out of 256 are for the f-stops beyond the 5 in this example).