This line appears in Hamlet's first soliloquy in Act I, scene two after he has learned of his mother's marriage to his uncle. Hamlet has grave reservations about the union, wishing that his mother had waited a little longer in mourning before choosing to wed again.
Hamlet does not trust Claudius, and certainly does not view him as a father figure.
"My father's brother, but no more like my father
Than I to Hercules" (I.ii.155-156)
Hamlet compares the contrast between his uncle and his father to himself and Hercules. The Greek mythology reference to Hercules creates an analogy for the reader that Hamlet must also see his dead father in a heroic, noble light. The contrast also reveals that Hamlet sees none of these heroic qualities in his despised uncle.
In Act I, Scene 2, in his first soliloquy, Hamlet expresses his dislike and opposition to his uncle Claudius, whom he perceives as the antithesis of King Hamlet, just as he, Hamlet, is completely unlike Hercules.
With the lines cited above, Hamlet conveys his resentment that his mother has so rashly married Claudius. In the lines that follow, he expresses this bitter indignation:
(Than I to Hercules) Within a month--
Ere yet the salt of most unrighteous tears
Had left the flushing in her galled eyes,
She married! O most wicked speed, to post
With such dexterity to incestuous sheets! (1.2.155-159)
Claudius is nothing like his father, just as he is nothing like Hercules. For, Hercules was a mythological hero of much action and strength, while Hamlet is a melancholic man, not a semi-god, and he is slow to action, deliberating constantly in subsequent soliloquies, just as in this first one.
Considered the greatest Greek hero, Hercules was not pensive as is Hamlet; instead, he was all physical strength--the strongest man to have ever lived. He was extremely confident of this strength as well; Hamlet deliberates and expresses uncertainty about himself throughout his soliloquies. While Hamlet procrastinates and writhes in his melancholy, Hercules makes amends for his mad act of murder by undertaking and completing twelve daunting challenges given him by Eurystheus, his cousin.