The rustic characters in Hardy's novel perform several functions. First, they provide local color. But more importantly, they represent and articulate the "view from below," the point of view of the lower classes, whose outlooks often weren't expressed in 19th-century novels. (We don't, for instance, get the viewpoint of rustics in Jane Austen's novels.)
Because Hardy's rustics have down-to-earth common sense, their opinion carries weight and helps characterize more important characters like Bathsheba and Gabriel as decent people.
Most markedly, we know Gabriel is a good guy because he can relate to the rustics, and they trust and respect him as a leader. He comes from similar roots, and when he is cast down to their social class by the misfortune of losing his sheep flock, he does not despise himself or fear working hard with his hands. In this novel, rustics represent a positive force, in contrast to corrupt figures like Troy.