Part of the tilt-shift effect comes from the camera's plane of focus. Normally, the plane of focus and the image plane are aligned, meaning you get even depth of field in a photograph wherever you decide to focus (foreground, background, etc.). Tilting the lens separates the plane of focus from the lens axis, so you can create a depth of field wedge. This technique can be used to put an entire photograph in focus, but it's often used to play with depth of field to help create the miniature model effect we mentioned earlier. Tilting is a way to gain more control over depth of field.
Shifting alters the relationship between a camera's image sensor and the lens's imaging circle. Light travels down the circular lens and is then captured and cropped by the rectangular image sensor, which is why our photographs are normally rectangular instead or round. When you're taking a tilt-shift photo, you're really playing with perspective. When the lens shifts, it separates the lens's center of perspective from the sensor's. By changing the part of the lens circle the imaging sensor captures, photographers can capture more of an image above or below the normal horizon of a photograph. That's why shift lenses are popular in architecture photography: They can change perspectives to capture tall buildings without leaning the camera back and creating unnatural perspective.