Every straight man has a stooge — Abbott had Costello, Crosby had Hope — the foil, the fool, the flunky, the goat. But for much of their career, after splitting from a famous straight man, the Three Stooges had only one another to kick and slap around. Beginning in the 1930s these immortal three ran amok for decades in some 200 short films, busting guts and raking in cash. Now, with stupidity a proud national pastime on the boob tube and off, the moment is ripe for a nyuk-nyuk revival, starting with “The Three Stooges: The Movie,” Peter and Bobby Farrelly’s thoroughly enjoyable paean to Moe, Larry and Curly and the art of the eye poke.

Set in the present, the movie is a fictionalized origin story about three sort-of-lovable fools who could be known as Dumb, Dumber and Dumbest, as Peter Farrelly originally pitched the movie. It’s a perfect fit for the Farrellys, who have made a career out of idiocy in comedies like “Kingpin” and have recently stumbled with duds like “The Heartbreak Kid.” Written by the Farrellys and Mike Cerrone, “The Three Stooges” imagines a once-upon-an-orphanage time when three babies are tossed out of a speeding car at the feet of a nun whose name, Sister Mary-Mengele (Larry David in a habit and snarl), announces that the filmmakers won’t be soft-pedaling their shtick.

The nun’s name proves something of a bait and switch because Sister Mary-Mengele turns out to be the most gleefully offensive jape in a movie that’s more sweet than sour. That’s par for the course for the Farrellys, whose vulgarity has always been leavened by their sense of decency and too frequently undermined by their sentimentalism. Even so, while “The Three Stooges” has a few aww moments, as might be expected given that it’s partly set in an orphanage, and although the Farrellys go soft on the Stooges’ relationships, the filmmakers never lose sight of the crude comedy that inspired them. The Stooges’ bonds of brotherhood may be strong, but they’re ties forged by a choreographed roundelay of resonant whacks and other instances of extreme discipline and punishment.