Going in, everyone knows that “McFarland, USA” is intended to be heartwarming and inspirational. The filmmakers know you see them coming, and so they know they have only one play available to them — to come right at you. Kevin Costner plays a legendary high school cross-country coach, so right off we know there’s going to be the scene in which the quiet man stands up and makes a speech, telling the team how much he loves them.

The film’s mission is to make you care about this coach, this family, this team, and this town; and “McFarland” does it. The surprise is that it does so methodically, expertly, never pushing you into feeling something unearned, and never making the soundtrack do their work. Go into this movie unwilling to be moved, and soon enough you’ll be tensing up and gritting your teeth and moving your head to nudge these kids across the finish line.

Costner isn’t the whole picture, but he’s a big part of its success. He is one of a precious handful of current actors who has that thing that the studio-era stars had, of embodying a moral idea on screen. With Costner in the cast, you don’t need the “USA” in the title, because the movie will automatically seem emblematic, an American story. It’s going to be about a stubborn and somewhat difficult guy, but one with fundamentally moral instincts, who rises above himself to do something good in the world.

Along the way, people will tell him off. Notice this about Costner’s movies, including this one: People are always telling him off, and he invariably reacts in the same way. He says nothing. He just looks at them stone-faced but placid, as if thinking, “That may be true, that may be false, but I have nothing to say at this time.” It’s a way of showcasing his character’s strength even while pointing out his weaknesses.

Based on a true story, “McFarland, USA” gives us the account of Jim White (Costner), who begins the film at a career low point. An outburst of temper has gotten him fired from a football coaching job, so he takes the only job he can get, as an assistant football coach at McFarland High, in one of the poorest towns in California. He moves his family to a crackerbox house in a dicey neighborhood, and director Niki Caro (“Whale Rider”) wisely finds nothing cute in this. This man has fallen far and has taken his wife (Maria Bello) and kids with him.

After a rocky start, Jim gets the idea to start a cross-country team after realizing that the school has some particularly fast runners. With the backing of the principal, he finds seven kids for the team — including a chubby guy — and starts training them. He knows nothing about track, but he’s willing to put in the effort, including getting involved in the lives of his runners.

More than just another sports story, “McFarland, USA” is also an immersion into the culture of Mexican immigrants who work the land. Most people watching will be surprised to learn, for example, that these kids would get up at 4:30 a.m. and work the fields for hours, picking lettuce and cabbages, before going to school. In this world, Jim White — nicknamed “Blanco” by his students — can only be an outsider, until, in an important scene, both for his and for our understanding, he works the fields with them for one day. He comes home exhausted and nearly crippled.

“McFarland, USA” could have been a sentimental film, but it’s not, because Caro and the screenwriters bothered to know what they were talking about. They took care to be specific and show the ugliness and the difficulty of life in a harsh, poor, immigrant town — for example, the store owner hosing off the blood in his driveway from the night before. Even good stories are never quite like a movie, and to its credit “McFarland, USA” doesn’t try hard to be like a movie. It tries to be something like life.