You are referring to Hamlet's famous soliloquy, "To be or not to be," in Act 3, Scene 1 of Shakespeare's Hamlet.
Hamlet has returned home for the funeral of his father. He has been away at school. Based upon what he says, the audience can believe that their family was very close. This is supported by Hamlet's deep and abiding grief over his father's passing. He is disgusted with his mother, who has married Claudius, King Hamlet's brother, so quickly— which the Elizabethan audience (and Hamlet) would perceive as an incestuous act.
He has also been visited by a ghost who claims to be his father. He senses that Ophelia has turned her back on him to spy for the king and for her father Polonius. Hamlet is struggling with finding purpose in life, and he is having thoughts of suicide.
Hamlet wonders to what purpose people stand up and fight the harsh realities of life, when dying would be easier. By simply dying, one could end the suffering of this world and simply "sleep." Ah, but what of the dreams that may come in that sleep? If death were such an easy solution, wouldn't thousands take the escape of suicide rather than be beaten by the hardships of life? A knife could end all the suffering, but those tempted must stop themselves because there is something unknown, on the other side, of which they are fearful—things the living know nothing about. Hamlet states that "conscience does make cowards of us all."
The hardships Hamlet mentions are: "a sea of troubles," "heartache," and "natural shocks." He is sure many would turn away from the following: "the whips and scorns of time," "the oppressor's wrong," "the proud man's [insults]," "the pangs of disprized love," "the law's delay," "the insolence of office," and the burdens "to grunt and sweat under a weary life" when death could be accomplished so easily. All of these images represent the daily difficulties humans face on a day-to-day basis.
This soliloquy poetically provides Hamlet with the opportunity to make a list in his head. There are two columns in this "discussion." Column A lists reasons "to be" (or to live), while column B lists the reasons "not to be" (or to die). In this way, this inner-dialogue offers Hamlet the chance to place all the "cards" on the table, separated into two groups: what if he lives, and what if he dies. He must have this conversation with himself to decide.
Hamlet at one point asks himself if he is a coward. By striving to survive, regardless of the heartaches he experiences, it is not cowardice that makes him hang on, but commitment to his father. It would be easy to end his life, even in the face of his fears, but he chooses instead to live: a noble choice.