Depth of field is a magical thing. With a low depth of field, a photographer can tell you a powerful story in a broader scene simply through what is in focus and what isn't. Depth of field can be shallow, like in the rose image above. To get this shot, I'm using my magical Canon 50mm 1.2 at a wide-open aperture of 1.2. For a landscape scene on the other hand, you'd likely want a very large or "deep" depth of field, such that as much of the scene as possible is in focus.
The lens on your camera can only be focused at one distance at a time. But there’s an area that extends outwards from the point of focus, both towards the background and towards the camera, in which objects still look relatively sharp. This is referred to as the depth of field. - Digital Camera World
While it is primarily the aperture or diameter of the hole inside your lens letting light into your camera that controls depth of field, other things matter as well. The focal length of your lens matters, where longer lenses (for example portrait lenses ~50-100mm) typically produce a shallower depth of field at the same aperture setting. The distance to the subject also matters. - which is why macro photography often produces some of the most abstract backgrounds. If you want to get shallow depth of field in your iPhone photos, for example, your best bet is getting really close to your subject and having the background you are shooting against be far away.
With the very short lenses, there is immense depth of field and if you want to throw the background out of focus it's going to be really difficult or perhaps impossible. This, by the way, is how the iPhone 3G gets by with a non-focusing lens. Apple's a bit vague on how big the sensor is, but it's around 10 sq mm with a 4 mm lens with such immense depth of field it doesn't need to focus. - Digital Camera World
The iPhone 3G has a non-focusing lens?! Who knew! Check out this cool info-graphic for depth of field decisions when shooting. Also, here is a chart for figuring out what your depth of field range is for a given camera and lens focal length, at different f-stop values.
But why does a wide-open aperture produce such a shallow depth of field? For the answer to that, you have to get into some physics! There are some great explanations of the physics of depth of field here and here. But essentially, it has to do with how light rays enter through your camera lens and fall onto your camera's sensor. To be perfectly in focus, the light rays bouncing or otherwise coming from your subject should enter your camera lens and fall on your camera's sensor such that they come to a single point, or as small a point as possible, on the sensor.
Now it turns out that with a small aperture (or a smaller hole letting light into your camera through the lens), there is essentially less "room for error" for those light rays to come down on different spots on your camera's sensor. With a larger aperture (like f/1.2) the "bent light cone" gets wider and there is a more limited range of the scene in front of your lens that you can focus on at one time. This diagram might help.
When a camera focuses, the focus is on one point. The light comes from the subject (represented by the X & Y) goes through the lens and the light is then put against film or a digital sensor. When the image is in focus, the light is converging (coming together) just right. When the light doesn’t come back together just right, the result is a blur. - PhotographyCourse.net
Want to learn more? Check out this article on depth of field for geeks!