Legends in the story
As Grandpa Longneck tells the children at the beginning of The Land Before Time VI: The Secret of Saurus Rock, The Lone Dinosaur was a legendary hero long ago - before Grandpa Longneck was alive, as he states later in the movie - who would just show up out of nowhere whenever there was danger afoot in a community. One day, what was declared the "biggest, meanest, most ferocious Sharptooth ever" came to the Great Valley, and while everyone ran away, the Lone Dinosaur appeared and battled with the Sharptooth on his own. His opponent managed to lacerate his eye, which apparently left a permanent scar running down the side of his face, but he emerged victorious.
A short while after he had defeated the Sharptooth and left the Great Valley, a rocky formation rose up out of the ground, shaped like a Longneck, with a ring of teeth encircling its neck. The teeth were said to be those of the same Sharptooth as the one he had killed. It was also believed (and later in the film seems to be proven true) that if the formation got damaged in any way, it would unleash its curse on the entire valley.
Comparisons in the present
Shortly after appearing in the Great Valley, he saved Littlefoot, who quickly went on to idolize the wanderer. Littlefoot believed Doc to be the legendary "Lone Dinosaur", who saved the Great Valley long ago from the most terrible Sharptooth. He based these assumptions on the fact that Doc can do fancy tricks with his tail; that he had been to the Great Valley before; that he has a scar on his eye, and that he has a resemblance to Saurus Rock. Cera, however, pointed out that the legends took place a long time ago, and that the real Lone Dinosaur couldn't still be alive, but Cera than doubts her theory on the speculation.
Role in the show and films
To a degree, after Littlefoot starts idolizing Doc, he places him above his own grandfather and defends him when he is accused of bringing bad luck to the Valley. Towards the end, Doc and Grandpa Longneck work together to save Littlefoot from an Allosaurus and a Tyrannosaurus; Littlefoot asks Doc to stay in case the Valley should ever need a hero; Doc replies that the Valley already has a hero and looks towards Grandpa Longneck. Doc has not appeared in any of the subsequent films.
In an episode of the TV series, The Lone Dinosaur Returns, Doc returns to the Great Valley. In the episode, he shows a great hostility toward the fact that Littlefoot is friends with Chomper. This severely weakens Littlefoot's view of Doc, but his respect for him is restored at the end of the episode when Doc apologises to Chomper, saying that he realizes that Chomper is different from other Sharpteeth. He is voiced by Kris Kristofferson in the film and Jeff Bennett in the TV series.
Doc is very reclusive, and tends to recede into the background whenever there's a crowd. He does not want to give away much on his history, perhaps to avoid the dinosaur's equivalent of media coverage. He has a brave and pure heart, as stated in the song, The Legend of the Lone Dinosaur, and indeed always shows up whenever help is needed. However, he calls it off each time as merely being "lucky".
His belief in luck is examined in The Secret of Saurus Rock when Littlefoot inquires if he believes in bad luck. He says that with all the bad luck he's seen happen, it's hard not to believe in it. He also theorizes that the way to handle bad luck is to change all that you can, and if you can't change something, just accept that and move on.
He claims "I'm a loner. That's the way I've always been." Sometimes, he says he feels lonely but "sometimes I feel a bit crowded too. My footsteps were planted on the wandering trail long ago. I'm too old to change it." Nevertheless, in "The Lone Dinosaur Returns", he has gotten himself a lady friend, named Dara, which Littlefoot finds surprising, as he feels you can't be a Lone Dinosaur if you're travelling with someone else.