His "to be or not to be" speech, is about the will to live. It is his choice whether to live (be) or not, so his free will starts with this most fundamental choice. In choosing to 'not exist,' he'd be escaping the external forces of history which have put him in an unfortunate situation. On the other hand, in choosing to be, he can then do his best to exercise his free will against, or in spite of, those forces.
To be sure, he is at the mercy of external forces. Claudius murders his father, marries his mother and his father's ghost demands revenge. Call it fate, god's will, dumb luck, etc., these events are beyond his control. Hamlet exercises his free will in how he plays and manipulates the 'players' (the characters in the play, Hamlet), who cause these events. He delays killing Claudius, to the ghost's dismay. He uses "The Mousetrap" to reveal Claudius' sin in front of the court. Prior to this, he resists killing Claudius while he's praying because this would be a better death than the one his father had. So, in waiting to expose Claudius in the most dramatic way possible, Hamlet is in charge of when the play's dramatic end occurs. Using the play (within the play), "The Mousetrap," Shakespeare is underscoring a kind of self-reflexivity. And it is this: The 'method to his madness' was Hamlet's manipulative method. He bewilders the other characters (Ophelia most harshly) in such a way that he not only wishes to control events, but the other characters' minds as well. Recall the line, "The play's the thing wherein I'll catch the conscience of the king." Since he manipulates events and characters' thoughts as well, he is, in a sense, writing what happens: he's writing his own play. Writing your own future is as free as it gets. But clearly, his mother's death and probably his own were not part of his plan. So he has free will to choose certain things, but he is at the mercy of the outcome: the dynamics of cause and effect.