As every schoolchild knows, the world’s first astronauts were animals. After all, you can’t just go sending humans into the unknown reaches of space! You need to try it out on a monkey first, to make sure it isn’t deadly. If it had been around in the 1950s, PETA would have been apoplectic with rage (which is just another reason to keep doing it, in my opinion), but that’s how things worked in those days.

The first monkey in space, way back in 1961, was a chimpanzee named Ham. With that page in history as its jumping-off point, the animated comedy “Space Chimps” follows the endeavors of his fictional grandson, Ham III, a lowly circus monkey who gets a chance to experience some of his grandfather’s glory when NASA comes a-callin’. The film is no classic, certainly, but it’s not one of those throwaway puff pieces, either. Nor does it rely solely on the premise that monkeys are always funny, though it could easily have done so. As one of the human scientists says while watching Ham III and the chimps undergo physical training, “I don’t know what makes me happier, Einstein’s unified field theory or monkeys on a treadmill.”

Ham, voiced by current “SNL” smirker Andy Samberg, is an irresponsible slacker, which means the trio of space chimps also needs a by-the-book commander and a female for Ham to fall in love with. That’d be Titan (Patrick Warburton) and Luna (Cheryl Hines), respectively, the former sporting the simian equivalent of a military haircut, the latter with soft eyes and red lips. A fourth chimp, young Comet (Zach Shada), stays behind with Ham’s mentor, the crotchety old Houston (Carlos Alazraqui), who by all rights should have been voiced by Clint Eastwood.

The mission is to investigate a wormhole that was discovered when an unmanned space probe recently got sucked into it and disappeared. What the scientists don’t know is that the probe wound up on a jelly-bean-colored planet inhabited by blobby, mostly harmless aliens. The cranky old man among them, Zartog (Jeff Daniels), has commandeered the probe and now uses it to wield control over his fellow creatures. All of this is presented in a silly, cartoonish fashion, however, lest the kiddies in the audience be frightened.

Ham, Titan, and Luna wind up on the same planet, and that’s where the usual lessons about believing in yourself and doing the right thing unfold amid loopy supporting characters (including an adorable giant-headed little tyke voiced by Kristin Chenoweth) and sly sci-fi jokes. Most of these are more for the grown-ups, as when Luna notices that there are three suns shining on this world and Ham says, “Just like every science fiction movie involving other planets guessed there would be.” Zing!

Back on Earth, the mission is controlled by a trio of scientists — a fat guy, a geeky woman, and an Indian-American — who fit the nerd stereotypes without being complete caricatures, and their interaction is more genuinely funny than I would have expected. In fact, the film in general is funnier than I anticipated. The pop-cultural references are kept to a minimum, generally spoofing sci-fi devices in general rather than parodying specific films. It’s Samberg’s smart-aleck (and aptly named) Ham that provides most of the laughs, both for the kids and their parents.