In Hamlet what was is the purpose of Horatio? And does he help convey the theme? If so how?
In Shakespeare's Hamlet, Horatio serves as a man of superior sense and a loyal friend to Hamlet. When the ghost appears to guards at the castle, it is Horatio that they go to. It is Horatio that they ask to come with them to corroborate the ghost's existence.
Hamlet trusts Horatio with confidential information. He tells Horatio that he will be putting on an antic disposition (Act 1.5.171), he will be pretending to be mad. And Hamlet, too, seeks corroboration from Horatio when he asks Horatio to watch the king's reaction to the play performed by the actors in Act 3.2. When he wants to trap the king and determine with certainty that the king is guilty, it is Horatio Hamlet turns to for help.
The enotes Study Guide on the play says the following:
Horatio is one of the few fixed points in the play: he remains from first to last a loyal friend to Hamlet, trusted by all. He attempts suicide when Hamlet is dying, but Hamlet asks him to remain alive to give a full account of the tragic events at the Danish court.
The least complicated "good" character in the play, Horatio is calm and stoical. He furnishes Hamlet with an anchor, and his allegiance to the prince is so great that he offers to die alongside his friend.
Concerning Horatio's contribution to theme, his most important role may be providing a figure for Hamlet to talk to. Hamlet's dialogue with Horatio reveals details of Hamlet's plans. The theme of madness, for instance, is contributed to when Hamlet tells him the plan already mentioned above to fake madness. Horatio's character gives Hamlet someone to confide his plans to, thereby revealing those plans to the audience.