I know that aperture changes the depth of field (DOF), but why is it that by making the image appear larger (by getting closer to the camera or zooming in) there is less DOF?
Depth-of-field is perceptual and dependent on viewing size. When you zoom on screen, you change viewing size. Most DOF charts are calibrated for an 8x10" print at 12" viewing distance but some online tools let you put in other numbers.
You see, there is only one plane of focus. Anything closer and further is out of focus except that the transition is gradual. So as the distance from the focus plane increases, do does the blur. At some point, the blur becomes high enough to be considered out of focus.
The larger you view something, the more visible blur is. So when you see something larger, the point at which it becomes out of focus simply occurs earlier.
Subject distance is an intrinsic factor in the depth of field formula:
Circle of Confusion (CoC) is a quirky factor here. CoC affects the "depth" of the scene that appears to be in focus. In reality, there is only one infinitely thin plane of focus, and blur increases as a function of distance from that plane. Depending on the output size of a photo (the size the image is scaled to for viewing), the CoC changes. Images that are scaled down and published on the web can support a much lager CoC, where as images that are scaled up and printed large support only a small CoC. CoC is limited on the lower bound by the spatial frequency of the sensor, which can range from 0.01mm to 0.02mm, so higher density sensors tend to be better for those who print, especially those who enlarge their photos two to three times for large prints.
You should also note that increasing focal length changes perspective any given subject distance, which is why you can zoom in and not move closer to your subject and get the same rough effect. The reason for this is due to the way long focal lengths compress the field, where as wide focal lengths decompress the field. The nominal focal length where the field of view appears to be the same as what we see is generally equal to the diagonal of the sensor, in which case the apparent DOF as a result of a normal perspective would be "normal" itself. (This is why 50mm lenses on 35mm form factors are called "normal" lenses.)
Depth of Field is really a function of magnification and F-Number. Magnification is a factor of subject distances (distance from lens to object and distance from lens to sensor). The differences of these distances result in more oblique angles of focused light rays as a subject gets closer to the lens or as the lens magnifies a subject at greater distance more, thus resulting in a thinner depth of field. This is also the same reason a larger aperture reduces the depth of field...more oblique angles of focused light rays.
When it comes to depth of field with telephoto lenses (lenses longer than a "normal" lens, such as 50mm on FF), they effectively achieve the same thing as focusing close, resulting in the same depth of field as a closer subject at a wider angle (i.e. same framing regardless of focal length). Visualizing the reason why long focal lengths still result in thin DOF is a bit counter-intuitive. It boils down to the compression of the field, which is why long lenses produce the kind of perspective they do, and have an apparent thinner DOF than one would normally (and naturally) figure.
In the figure above, the third diagram (blue) has the same DOF as the first diagram (green), despite the fact that the actual focal plane is farther away. Compression of the field is visualized at the bottom, hopefully demonstrating the reasons why a long focal length results in softer looking backgrounds and thin DOF. It should be noted that on a size-normal basis, longer focal lengths do not actually blur any more than wide focal lengths, and for any given subject framing the depth of field is actually identical. The appearance is somewhat illusory given the compression effect that focal lengths longer than "normal" have. The background is enlarged with a longer focal length, which tends to produce a softer appearance with the same amount of blur relative to the objects visible in the frame.
In a way, depth-of-field is an illusion. There is only one plane of focus. Everything in front of or behind the point of focus is out of focus to one degree or another. What we call DoF is the area where things look, to our eyes, like they are in focus. This is based on the ability of the human eye to resolve certain minute differences at a particular distance. If the slightly out-of-focus blur is smaller than our eye's capability to resolve the detail then it appears to be in focus. When you magnify a portion of an image by making it larger or moving closer to it you allow your eye to see details that before were too close together to be seen by your eyes as separate pieces of the image.
Since things are gradually blurrier the further they are from the point of focus, as you gradually magnify the image the perceived depth of field gets narrower as the near and far points where your eyes can resolve fine details moves closer to the focal plane.
If you are viewing the image on the camera's built-in screen there is something else going on as well. A typical DSLR sensor may have a resolution of about 20MP. A typical screen may have a resolution of about 1MP. Some of the the detail in the image the sensor recorded is being combined to fit on the lower resolution screen. And although I've never read this, I think that camera manufacturers tend to sharpen the images as much as they can for the camera's screen so the pictures will look better to the photographer.