RAW files are comprised of raw image data and metadata that contains all of your camera settings you used to take the picture. When you shoot RAW, your camera retains (in theory) all of the light information that strikes its sensor (CCD or CMOS) in an "as-is" state, and then stores the file, along with the camera settings information, in a lossless compression format. Basically, your selected color profile and color balance settings don't matter; you can simply change them retroactively on your computer because the RAW file saved all the relevant data.
iPhoto uses the 16-bit RAW data to facilitate your edits before converting the RAW file to JPEG. This gives you greater editing flexibility since the RAW image's superior exposure latitude is retained. (An image's "exposure latitude" refers to how far you can adjust the exposure or white balance while still retaining acceptable quality.)
When you shoot straight to JPEG, your camera looks at your white balance and color profile settings, then discards all information that is not required to make a JPEG of your selected grade with those color settings when it produces the image.
Because information is discarded, a JPEG has less latitude for retroactive correction than a RAW file does. Say, for example, that you had your camera set to ISO 400 when it should have been set to ISO 1000; your exposure will be underexposed (it'll come out too dark). That's not a big problem if you captured a RAW image because you can just bump the exposure a stop and a half without worrying too much about image degradation. With a JPEG image, you'd have less color information to work with, so loss of image quality will factor into play.
The flexibility of RAW shines most when you wind up with a really bad exposure. Take, for example, this overexposed picture of Sidekick, the lounging brown tabby. While the camera exposed the back of the play tunnel correctly, our intended subject is looking pretty washed out.
In fact, the lighting in this exposure is so uneven that we can't make it uniformly perfect in iPhoto, so we'll just concentrate on making Sidekick look as good as possible instead of trying to perfect her play tunnel too. To demonstrate how RAW and JPEG photos react differently, we applied the exact same adjustments (shown on the right) to both images.
Here's Sidekick after we applied the adjustments to the original RAW image:
And here she is again after we made the adjustments to a JPEG:
Note how the color, contrast, and detail in Sidekick's fur remain at a higher quality in the RAW version than in the JPEG image. In this particular case, the front of the tunnel below Sidekick is a bit bright, but remember that our goal was to make her look good.