The moon completes one orbit around Earth with respect to the distant stars every 27.5 days. This constitutes a sidereal month. In contrast, the lunar cycle of 29.5 days is called a synodic month. It takes the moon an additional 2 days to begin a new lunar cycle because Earth is not stationary in space, but instead moves as it orbits the Sun.
In the time it takes for the moon to complete one orbit around Earth, the planet has moved in its orbit around the Sun. It takes the moon approximately 2 days to "catch up" to Earth's new position relative to the Sun as seen by an observer on Earth.
The moon's 29.5 day synodic month was the basis of lunar calendars throughout the course of history. While a lunar calendar was convenient, it presented an immediate challenge: Compared to the solar year of 365 days, a lunar year lasts an average of 354 days. Some groups decided to ignore this discrepancy. Others, including the creators of the Jewish calendar, decided to intercalate these two cycles by adding an extra month of 30 days every two to three years. The intercalation cycle, corresponding to the Saros cycle of the Moon's orbit, repeats every 19 years, which works out to 7 leap years in every 19 year cycle.