Definition
A lunar calendar counts days by the changing shape of the moon. The day the moon hides and can't be seen (the new moon) is the first day of the month, and each month is counted as 29 or 30 days. That puts the round full moon around the 15th.
Counting the Days by the Shape of the Moon
Picture the moon in the night sky, changing a little every day. It starts as a thin crescent, as slim as a fingernail. It slowly fills out until it becomes a round full moon. Then it shrinks again into a slender sliver and finally disappears completely. That's the new moon. People long ago had no clocks or paper calendars. They could just look up at the moon and know roughly what day of the month it was.
The moon's shape goes through one full cycle in about 29.5 days, from one new moon to the next. The moon actually circles the Earth in about 27.3 days. But the Earth keeps moving around the Sun in the meantime, so the moon takes a little over two extra days to return to the same shape. The angle at which the moon catches sunlight keeps changing, and so does the look of the moon from Earth. These changes are called the phases of the moon. The lunar calendar is built on exactly this visible cycle. If the day the moon turns away from the Sun and can't be seen (the new moon) is the 1st of every month, the round full moon rises around the 15th. In some years it comes on the 16th or 17th.
There's a catch. The moon's cycle is 29.5 days, so it doesn't divide into whole days neatly. A lunar calendar doesn't split a day in half. Instead, it follows the day the new moon actually arrives. Some months get 29 days (a 'short month') and some get 30 days (a 'long month'). Sometimes two long months or two short months come in a row. Mixed together like this, the average month is about 29.5 days. The calendar date and the moon in the sky line up almost uncannily well.
A Compass for the Sea and the Night Road
Go down to the beach and you'll see the water rush in and then slide back out. This is the rising and falling of the tides. It happens because the moon pulls on the Earth's ocean water. The water level changes with the moon's position. So if you knew the lunar date, you could easily guess when the water would be at its highest.
For fishers heading out to sea, or people digging clams on the mudflats, the lunar calendar was far more useful than a solar one. Around the 1st and the 15th of the lunar month, the gap between high and low tide is biggest. That's the spring tide. Around the 8th and the 23rd, the gap is smallest. That's the neap tide. The sea's tides and the lunar dates moved together as one.
In the days before electricity, people could also tell in advance how bright the moonlight would be on a dark road, and when the tide would come in and go out. That made the lunar calendar one of humanity's most dependable everyday compasses for the night and the sea.
To Be More Precise: It Follows the Sun Too
To be more precise, the lunar calendar people have traditionally used isn't purely lunar. It's a lunisolar calendar, which also takes the Sun's movement into account. If you go by the moon's shape alone, 12 months add up to only about 354 days (29.5 days × 12 months). That's about 11 days shorter every year than the time it takes the Earth to go around the Sun (about 365 days).
Leave that gap alone, and in just three years the calendar runs about a month ahead of the seasons. After a dozen or so years, snow could fall in a summer month on the calendar, and a heat wave could hit in a winter month. Farming depends on knowing the seasons exactly. If you only chase the moon's shape, you'll miss the right time to plant seeds entirely.
To fix this, people added a bonus month, a leap month, about seven times every 19 years. In a year with a leap month, the year has 13 months, and the gap between the calendar and the seasons quietly closes. People also used the 24 solar terms, which split the Sun's path into 24 points, to keep the seasons lined up tightly.
Common misconceptions
The lunar calendar was made for farming.
For farming, what matters is the movement of the Sun, which tells you about the changing seasons. A purely lunar calendar drifts away from the seasons by 11 days every year. So farmers mainly relied on the 24 solar terms, which are based on the Sun's position, and on solar calendar principles.
Where you meet it
Holidays like Lunar New Year and Chuseok (Korea's harvest moon festival) are set each year by the lunar calendar.
When you go clamming on the mudflats at the beach, checking the tide times (when the tide comes in and goes out) uses the same lunar principle.
In one sentence
A calendar built on the moon's changing shape, with a leap month added to keep it in step with the seasons.