"To be or not to be."
Translation:Att vara eller inte vara.
It's largely idiomatic. You could very well say att vara eller inte att vara (or att vara eller att inte vara). In the same way, the English sentence could have been to be or not be (or to be or to not be). But that's not how Hamlet is usually translated, nor how it was written. :)
The rule is that inte normally goes after the verb in main clauses, but before it in subclauses. However, this rule only applies to the kind of verb that shows time, but att vara is in the infinitive so it doesn't apply here. In terms of word order, att vara behaves like a noun, so that inte typically wants to go before it. (Det är inte en bok 'It isn't a book') – inte goes after the verb, but before the noun.
Compare: I do not like books or I do not like to read – not is after the verb which shows time, do, but before the infinitive to read or the noun books.