Sometimes, things just don't always work out the way you might want. The exposure for the foreground blows out the sky, or the exposure for those clouds makes the foreground too dim. Traditionally this was fixed by using ND grad filters, or split ND, to basically block some of the sky's light. Digital gives us a couple of extra options.
Basically, using a tripod, or someway of registering the images together later, you can take a "light" image and a "dark" image, and take the best bits of each of them. I originally read about this technique at The Luminous Landscape
If you came to this page, you probably clicked on an image where I used this technique to produce a "better" image. I use an automated version of Luminous Landscape's "Layer Mask" technique. I use image magick, and a shell script to stack the images.
You can get a copy of the script here, you may find it useful: photo-stack
Oh yeah, sometimes the stacks are made with two separate exposures, sometimes with two different "developments" of the same camera raw file.