You can think of each of these characters as a foil to the character of Hamlet and each of them highlight his virtue, though not always directly. A "foil" is a literary device wherein one character highlights the qualities of another character. (The way I always remember this is to think of literal foil, like aluminum foil, that acts as something of a mirror by reflecting.) Fortibras, Laertes, and Horatio all reflect the qualities of the protagonist, Hamlet, each in different--and not always complimentary--ways.
Let's begin with the character who serves as the sharpest foil to Hamlet, Fortibras. Whereas Hamlet is always stymied by thought, Fortinbras (much like Hamlet's own dead father) is a man of action. While Hamlet wrings his hands about what is to be done and how Claudius will and must be caught, Fortinbras is marching through Norway into Denmark on his way to Poland to capture some worthless land. Hamlet marvels at the news, saying:
Two thousand souls and twenty thousand ducats
Will not debate the question of this straw:
This is the imposthume of much wealth and peace,
That inward breaks, and shows no cause without
Why the man dies (4.4.26-30).
Fortinbras, for very little reason ("ambition puff'd, / ... even for an eggshell"), has decided to risk the lives of his men and spend thousands just for a worthless patch of land ("hath in it no profit but the name"), land that will not increase his territory by much and certainly not profit him ("a little patch of ground"). When Hamlet dies, and effectively turns over the kingdom to Fortinbras, he opts for a man of action rather than a man of thought. His way of internal debate, he sees, has not exactly worked out. But even though Fortinbras does not generally foil Hamlet's better qualities, Hamlet's hesitation to condemn thousands of souls to needless deaths speaks well of his morals.
Laertes is yet another foil for Hamlet. Laertes is Ophelia's brother and the person who stands in the way of allowing Hamlet to completely use Ophelia to achieve his own ends, that is, the capture of Claudius. While some scholars doubt whether Hamlet actually loves the girl, I contend that he did. Laertes purer love for his sister--not inhibited by sexual desire, nor by a reason to use her to achieve anything--makes Hamlet realize, upon her death, that she has died because of him. His outrage,
I loved Ophelia. Forty thousand brothers
Could not, with all their quantity of love,
Make up my sum. What wilt thou do for her? (5.1.269-271)
must have sounded hollow even to his own ears. To quote another line from Hamlet, he "doth protest too much." So, through Laertes, we see Hamlet as both a man who loves and a man who loves imperfectly (to put it mildly since his love was torn by inner conflict). Without Laertes as a contrasting foil, we might never have seen this dual reflection of the Hamlet's character.
Horatio, as a foil, perhaps brings out what is best about Hamlet. The prince is the most comfortable around his lifelong friend. The two had been at university together. It is Horatio who first sees the ghost and convinces Hamlet that it is real. Like Hamlet, Horatio is prone to thought, not action. As Horatio's friend and confidant, we see Hamlet at his most trusting and relaxed. It is in Horatio's arms that Hamlet takes his last breath, and it is Horatio who has one of the most tender lines in all of literature: "Good night, sweet prince. / And may flights of angels sing thee to thy rest."