Ok. Here's my answer.
The "ship" needs to be big, so big that it's capable of providing a self-sustaining, self-regulating environment like the Earth's biosphere does. No air filters to change; instead, forests of trees will provide oxygen. No algae sludge farms; regular farms will do nicely. People have been growing their own food for thousands of years, and they can do it for thousands more here. A hollowed-out asteroid, spun up to an appropriate speed to provide gravity, would be suitable. The cylindrical interior of this "ship" is like a small, inside-out planet where people can live and breathe easily, as they would in their natural environment back home. The larger the asteroid, the more robust the environment, and the more room for a larger human population which will maintain better genetic fidelity over time. A space 2 km in diameter and 2 km long provides 12.5 km$^2$ of livable surface area and 6.28 km$^3$ of breathable air, sufficient for 10,000 people at a population density of 1.25 hectares per person. Some kind of "sunlight" will be required: I suggest a nuclear energy source, designed to last for millennia without maintenance. Why give people the chance to muck up such a vital component? No need. Nuclear fission (or fusion) can burn for a loooong time.
This makes maintaining a stable living environment easier, but it doesn't solve everything. You still need people to:
Remember their technology. What's the point of travelling to a distant world if, by the time you get there, your people have regressed to the stone age? They won't even be able to get off the ship. Language retention will also be important, so they can read the ancient texts and follow the recorded instructions for landing once they finally get there.
Take care of their environment. If you think this is important on Earth, it's ten times as important in a relatively small, enclosed space capsule like this. Pollution, deforestation, overpopulation, and extinction (not to mention war) need to be absolutely avoided. Religiously, in fact.
Religion, or something like it, is the key to making sure this happens. The mythology of this religion is simple, and it's extra compelling because it's completely true: this world we inhabit is actually a vast ark, sent off long ago to travel through the universe to another, vaster, distant alien world. Some day, we'll get there... and when that happens, we need to be ready.
As you can see, it's got something in common with some of the more popular Earth religions, stories which have stood the test of time. There's the "chosen people" narrative (always a winner) which in this case includes everybody on board - but, our spacefaring acolytes still have the mythical schlubs back on Earth to feel superior to, so it's not all bad. Then there's that "day of reckoning", "end times", "world beyond our world" angle... we know humans dig this kind of thing.
But in case this isn't enough to make it stick, we can borrow an even more powerful trick from an even older period of human history. Nearly all ancient tribes used rites of passage to cement a young person's relationship to the ethos and mythos of the group. This form of ritual has been so pervasive because it's so effective, and of course it's still around today. The Marines use it. Fraternities use it. Cults use it. The idea is to use drugs, fasting, or some other means to induce an altered state of consciousness, break down psychological barriers, and induce a state of "imprint vulnerability", wherein the subject's mindframe is susceptible to permanent, groundbreaking change. Fraternities use peer pressure, humiliation, and beer for this purpose; cults may use faith healing demonstrations, group hysteria, or psychedelics; the Marines use intense physical training, camaraderie, and the horrors of war. All good, but we've got something even better. Let me tell you a little story to illustrate.
A girl is born in a village near one end of the "ship". As a child she's exposed to the standard mythology and tenets of her world's religion, and accepts it unquestioningly, as children do. We are a chosen people, approaching a great destiny; we must shepherd our world, keep all things in balance, maintain peace with our neighbors, and learn the ancient language and knowledge so that one day, when our time of reckoning comes, we'll be ready. All this she takes for granted. Eventually, though, she starts to grow up and to question her place in the scheme of things, and wonder whether any of it really makes sense. This is fine; it suggests that she's maturing intellectually and is ready to begin learning the deep magic of the ancients (electricity, metallurgy, semiconductors, photolithography and so forth). However, there's really no room for deviation from the principles in this society, so the point needs to be brought home in a big way that this is real, and an imprint created of this epic, magical sense of manifest destiny that will last for the rest of her life. So, as happens to all children on the eve of their adulthood, she's sent to the far end of the world (a pretty short walk, in this case) where there is the entrance to a cave. All kinds of symbolic rituals could take place here. She could strip naked and be covered in paint; the cave could be on a sacred island on the far side of a swamp where she'll be rowed across at night by masked, chanting monks. It doesn't matter: this part can evolve organically, as rituals will do. What's important is what's inside the cave. Also, preferably, that she not have the slightest idea what's in there before she enters. The bigger the mystery, the bigger the fear, the bigger the impact.
It's dark inside, to start with. Soon after leaving the entrance behind, it's completely dark. The floor is smooth, though, and there's only one way to go. Feeling her way along, she hikes up a steep incline, initially out of breath; but after some time, she begins to notice something different. Incredible as it seems, she's growing lighter. Each step seems easier than the last, until she's basically swimming through the air, unfettered by gravity. At this point, a slight glow begins to fill the cave again. It's not much, but her eyes are by now highly attuned to the darkness, and the faintest glimmer of light is visible. This makes the next part even more mind-blowing, as she comes around a final corner, into a vast, transparent half-dome at the very nose of the ship, and sees - for the first time - the stars.
She's never gonna forget that. Ever.
When she gets back, and her training begins, there's even more in store for her: science, the knowledge of the ancients, will start to reveal its mysteries, explaining everything she just saw and more. It might seem that this is giving away the magic, but any scientist will tell you that a greater understanding of nature doesn't in any way cheapen the thrill; totally the opposite, in fact. That's important, because these people are going to need everything they've ever learned, and furthermore they'll need the ability to discover, adapt and invent. This can't become one of those dead religions, where people accept what they're taught and follow it blindly until they die. People need to not just understand technology, but be capable of creating it for themselves. That their survival is basically pretty easy, with not a lot of work required to maintain it, definitely helps. There should be plenty of time for learning and intellectual pursuits.
Strong critical thinking skills, widespread education, a generally prosperous and easy lifestyle, a decentralized, democratic society, and a powerful sense of common purpose should be enough to keep this community peaceful, intelligent, and healthy - at least until they arrive. At that point - well - anything could happen. :)