The Moon's Origin
To understand why the moon rises and sets, it helps to understand how the moon came into being. The prevailing theory is that the moon formed after a Mars-sized planet collided with Earth, tens of millions of years ago. Some of the material from this planet fused with Earth, while the larger portion of it eventually formed the moon. Computer models of this collision show that the moon's current rotation, distance from Earth and orbital characteristics conform with this theory.
Gravity
The theorized impact of a celestial body with a much younger Earth helps to explain the moon's formation and distance, but gravity explains why it maintains a steady orbit around Earth. Relative mass and distance between celestial objects play an important role in the overall strength of gravitational force. The moon, being much smaller than the Earth, rotates within Earth's gravitational field, rather than vice versa.
Lunar Cycles
The moon takes 27.3 days to orbit Earth, but when you add in the extra distance it must travel as a result of Earth's orbit around the sun, the total time is actually 29.5 days. This orbital period is responsible for the phases of the moon: We see a full moon when the moon is directly opposite the sun, relative to Earth. A new moon occurs when the moon lies between Earth and the sun.
Appearance From Earth
The last piece of the puzzle is the rotation of Earth itself. Earth's gravity holds the moon in orbit, and this orbit changes the moon's appearance as seen from Earth. The reason the moon appears to rise and set, however, is that Earth is rotating on its axis; as it rotates, the moon seems to rise in the east, travel across the sky and then sink in the west. In fact, the moon orbits Earth from west to east, but since the moon's monthly orbit is much slower than Earth's daily rotation, observers on Earth see it moving in the opposite direction.