What he decides to do that the end of this very long speech is to go ahead and put on a play that will help him figure out whether Claudius is really guilty or if the ghost has just been sent by the devil to trick him (Hamlet).
He thinks of the play because he has just watched an actor give a performance. He berates himself for being so slow to act when even this actor can show all his emotion over something that is not even real. By contrast, Hamlet can't get angry enough over his father's death to do something about it.
That is what makes him think that a play is "the thing."
Hamlet has been paralyzed by indecision over whether or not to obey the ghost's commands to kill Claudius. Hamlet hesitates because is unsure whether the ghost is a devil sent to lure him into evil or truly the ghost of his father. After he sees the player so movingly act out Hecuba's grief, Hamlet, who feels genuine grief for the death of his father, is spurred into action. He decides that a play that enacts a murder just like the one the ghost described would so shock Claudius, if he were guilty, that he would betray himself. Hamlet is behaving here rationally and logically: he doesn't want to have innocent blood on his hands, and it does make sense to run an experiment to see if Claudius is guilty. As Hamlet says of the ghost, it:
May be the devil, and the devil hath powerT' assume a pleasing shape. Yea, and perhapsOut of my weakness and my melancholy,As he is very potent with such spirits,Abuses me to damn me.
I’ll have groundsMore relative than this. The play’s the thingWherein I’ll catch the conscience of the king.