A very good explanation from infinytyws.
If I may add further :
If you've saved the file in raw mode when it is subsequently loaded into a raw conversion program and then saved to a TIFF or PSD format file and it can be exported in 16 bit mode. The 12 or 14 bits recorded by the camera are then spread over the full 16 bit workspace. If you saved the file in-camera as a JPG than it is converted by the camera's software to 8 bit mode and you will only limited levels to work with.
Reasons to Shoot JPG
— Files are smaller and therefore more of them fit on a card.
— For many applications image quality is more than sufficient (family snapshots, news images).
— Small files are more easily transmitted wirelessly and online. This is important to newspaper photographers.
— Many photographers don't have the time or inclination to post-process their files.
— Many cameras (especially digicams) can not shoot quickly when working in raw mode. Some lower-end models can't record raw files at all.
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.
Something to consider is that every digital camera is indeed always shooting in raw mode. But, if we choose to save the file as a JPG we are committing to the raw conversion program that is built into the camera. If we allow the file to be saved in raw format though we have the opportunity to do the conversion on a more sophisticated platform, and to do so again and again if there's any benefit to this in future. In other words, the decision is — do you want to do the raw file conversion now in the camera, or later on your computer?
With a JPG file you are largely committing yourself at the time of exposure to several of the most important aspects of image quality, namely white balance, overall contrast, colour saturation and the like. With a raw file you are free to make decisions about these settings at your leisure.
Because JPG files require little or no additional processing when adjustments are made in post-processing, care needs to be taken to keep these within a limited range, or processing artifacts will be seen. For some photographers the ease and speed of use is a benefit, for others not. Certainly anyone looking for the best possible image quality will want to shoot in raw mode whever possible.
Some cameras can save both raw and JPG files simultaneously, and for many photographers this is an ideal solution. It provides a ready-to-use image for many applications, while a raw file is available for later and more comprehensive processing. The only downside to this double format is the extra space that it takes on memory cards
(Note: Extract from luminous landscape - understanding series)