The title The Moon is a Harsh Mistress summons up a very particular image, doesn't it? You can absolutely picture the moon personified as an old-timey schoolmistress, her hair in a tight bun, a hobble dress constricted about her, a scowl permanently etched into her straight-edged face as she strides down the rows of desks with a ruler griped tightly in her talon-like hands. And you know what? That's basically what this title is going for.
The phrase comes from a speech Professor Paz gives to the Chairman of the Lunar Authority during his time on Earth. As Prof says:
"[…]; I accept the title—nay, I glory in the title of 'jailbird.' We citizens of Luna are jailbirds and descendants of jailbirds. But Luna herself is a stern schoolmistress; those who have lived through her harsh lessons have no cause to feel ashamed. In Luna City a man may leave purse unguarded or home unlocked and feel no fear… I wonder if this is true in Denver?" (17.31)
Prof directly relates the moon to a stern schoolmistress and calls her lessons "harsh"—and with that, dear Shmoopers, we have ourselves a title. The question we need to ask now is why the title wants us to focus on this specific part of the novel? What's so special about Prof's speech here as opposed to the many other speeches he gives? Because seriously, he gives a lot of speeches.
As hinted at in the quote above, the moon's landscape isn't exactly hospitable to human inhabitance: no native air, water, or plants and no absolutely no atmosphere. Sunbathing equals death on Luna. Yet even its harshest lessons manage to educate that bunch of jailbirds who call Luna home. These criminals may not be the cream of the societal crop, but they take their Luna lessons and craft a society that Prof believes is superior to any found on Earth.
Depending on preference, it could even be considered a utopia. As Prof mentions, there is no theft and no fear of theft, and when talking with Stu, Mannie argues there is no rape on Luna (11.123), that every man pays his dues (11.128), and all acts of violence are justified (11.130). All this in a society founded by criminals and ne'er-do-wells.
The title suggests that the lessons of Luna—and therefore the lessons found in the book as well—are harsh, but the result will be a stronger, better individual. And better individuals breed better societies. This harsh mistress, then, is the gift that keeps on giving.