Ham is Peggotty's nephew, the son of her brother Joe Peggotty, who drowned when Ham was a child. So, Ham is an orphan who has been raised by Mr. Peggotty to follow in his footsteps as a fisherman. Oddly, Ham is also present at David's birth as a young boy: Peggotty had asked her nephew to be on hand to run errands during Mrs. Copperfield's late pregnancy.
Like Mr. Peggotty, Ham is a strong, sturdy man whom David admires for his good nature. At the same time, despite all of Ham's great qualities, we cannot help but notice that David condescends to poor Ham. For example, when Ham and his beloved cousin Emily get engaged, David describes Ham's face as lit up with a "lumbering sort of bashfulness" (21.123). "Lumbering" and "simple" are two adjectives David often attaches to Ham, suggesting that he is not too bright. Ham is clearly marked as a working man, a laborer, of an extremely different social class than David's own.
Still, even if David continues to affirm that Ham is socially (and intellectually) beneath David himself, he does not approve of Steerforth's easy dismissal of Ham's feelings. In fact, David is so upset when Steerforth describes Ham as too "chuckle-headed" (21.158) for Emily to marry that David has to convince himself Steerforth doesn't mean it and is joking. David may not respect Ham's brain much, but he truly admires Ham's heart. And it is the nobility of his heart that leaves a lasting, heroic impression of Ham as a character.
When Emily deserts Ham, he stays on at Yarmouth and continues his work as a boat-builder. Everyone notices that Ham throws himself even more bravely into his work, even though, as Peggotty remarks, he is "broken-hearted" (51.93). But the strongest demonstration of how remarkable Ham truly is comes when David returns to Yarmouth with the news that little Emily has been found safe (though still too emotionally fragile to return to Yarmouth herself) in London. Ham asks David to use his superior education to convey a message to Emily.
Ham doesn't know how to put what he wants to say into words, so he relies on "Mas'r Davy" (51.99) to tell her. Ham doesn't want Emily to worry about him, so he wants David to assure her that Ham still misses her, but that he hasn't been too badly hurt by her treatment. Ham is so very self-sacrificing that, far from being angry at Emily for her desertion, he wants her to forgive him. He feels he was being insensitive when he didn't notice her reluctance to marry him. Ham "loved her" and "the mem'ry of her" (51.110) too much to bear thinking of her suffering any more on his account, so he deliberately asks David to downplay how much Ham is hurting. We don't know if we could be so generous to a fiancée who left us for another person!
There are a couple of interesting things about this speech: first, it shows one of the major lessons of this novel, that what really makes a good person in David Copperfield is the degree of sympathy he or she has for others. We can compare Ham's quiet self-sacrifice to the selfishness of repulsive characters like Mrs. Steerforth.
And also, Ham's nobility seems to come in part from his recognition of David's social superiority. Throughout this whole speech, he calls David "sir" and remembers his childhood title of "Mas'r Davy." And at an earlier point, Ham begs David to find words for him: "You're a scholar [...] and know what's right and best" (31.47). Ham has total faith in David, which obviously goes a long way to making David respect him back. In the rigid social structure of this novel, his nobility as a character seems to depend, at least in part, on his willingness to be humble before his social superiors.
It seems almost too fitting that Ham dies trying to save the lives of the people stranded on a boat off the coast of Yarmouth during a terrible storm. He dies saving people. And one of the people he tries to save, even though this man has done him nothing but evil, is James Steerforth. It's tough to get more self-sacrificing than this.