In this famous text from Shakespeare's Hamlet, there is a comma after the first "to be". My interpretation is that the comma is placed here so that the reader (and much more importantly, the actor) will pause after the first "to be" and then continue with the rest of the sentence. This sets the two options up as contrasting opposites: "to be" (to continue living), and "not to be" (to commit suicide).