This sentence is indeed regarded as one of the most difficult translation challenges. This sentence has been translated variously by many translators. Kawai Shunichiro, one of the translators of Hamlet, has the list of 40 translation attempts that have been made by experts. To list a few:
- アリマス、アリマセン、アレワナンデスカ
1874年、チャールズ・ワーグマン
- 死ぬるが増か生くるが増か 思案をするはこゝぞかし
1882年、外山正一(『新体詩抄』所収、丸屋善七発行)
- ながらふべきか 但し又ながらふべきに非るか 爰が思案のしどころぞ
1882年、矢田部良吉(尚今居士)(『新体詩抄』 所収、丸屋善七発行)
- 第一、生きて居るか、死なうといふ事を考へる
1903年10月、土肥春曙・山岸荷葉(翻案『沙翁 悲劇 ハムレット』 冨山 房)
- 定め難きは生死の分別
1905年、戸澤正保(戸沢姑射)(『沙翁 全集 第一巻・ハムレット』 大日本図書)
The full list is available on Kindle. If I counted correctly, 32 attempts directly use words of life/death (生きる, 死ぬ, 長らう, 存【なが】ふる, 消えてなくなる, 生き続ける, 生死, 世にある, ...). Three attempts use ambiguous ある (ある/ありません, あるべき/あるべきでない, ...). One attempt uses やる, and one attempt uses する, as if the sentence were "to do, or not to do". The other three translations keep the sentence ambiguous by using どっちだろうか, これでよいのか or このままでいいのか.
Don't ask me which is the best one :-) 生きる/死ぬ may not be the most literal translation, but translators have to consider many things...
Anyway, probably the best-known translation is "生きるべきか死ぬべきか、それが問題だ." Parodies of this phrase are usually based on this (eg 食べるべきか). Kawai himself also adopted this phrase in his translation made in 2003, because he thought this is the sentence known to the general public.
もうひとつの本書の特徴として、To be, or not to beの訳がある。大抵、新訳が出るとなると、この部分の訳はどうなるのかと注目を浴びるところだ。そこで訳者は懸命に自分なりの解釈を考えることになる……。私自身、「忍びて在るか、たちて果てるか」などいろいろと考えたが、結局、訳者の解釈を押し付けることはやめて、観客が最も受け入れやすい台詞にすることにした。これまで最も人口に膾炙してきた訳といえば、「生きるべきか、死ぬべきか、それが問題だ」であろう。ところが調べてみると、この表現は、どの翻訳でも使われたことがないのである。参考書の類には載っていても、作品の翻訳として使われた経緯はないのだ。しかし、「生きるべきか、死ぬべきか、それが問題だ」ほど、ハムレットの独白の出だしの言葉として認知された訳もないだろう。
(シェイクスピア; 河合 祥一郎. 新訳 ハムレット (角川文庫))