Grandfer Cantle is goofy, but we kind of love him. He's definitely around for purposes of comic relief, which is a staple in most tragedies. Think of characters like the Nurse in Romeo and Juliet – she provides some much needed humor amidst all the melodrama.
Grandfer Cantle is always doing something inappropriate, from dancing to singing to saying things that he really shouldn't. He generally goes around making a fool out of himself and embarrassing his kid.
Immediately outside, in the passage, appeared Grandfer Cantle singing in concert with those still standing in front of the house. He came into the room and nodded abstractedly to Wildeve, his lips still parted, and his features excruciatingly strained in the emission of the chorus. This being ended, he said heartily, "Here's welcome to the new-made couple, and God bless 'em!"
"Thank you," said Wildeve, with dry resentment [...]. (1.5.62-3)
Grandfer Cantle notably speaks in local dialect, like the other lower-class residents of the heath that comprise the Egdon chorus. What's a chorus? They were a group of characters in Greek plays that helpfully delivered exposition, or background information, and commentary on scenes. Hardy turns the residents of Egdon into his tragic novel's chorus and, as such, they provide a glimpse into the local community, commentary on events, vital information, and humor. Grandfer Cantle takes care of the humor side of things, at least.