How to properly write the expression "the best of both worlds" and the shorter phrase "both worlds" (meant in the same context as in the larger phrase) in Classical Latin?
An alternative, more classical phrase for "world" would be orbis terrarum (literally, circle of lands). So "both worlds" would be orbes ambo terrarum and "best of both worlds" would be optima orbium amborum terrarum. This is awkward, so prefer optima mundorum amborum if you are OK with post-classical usage. Also, if the context is clear, optima orbium amborum would work (cf. the papal blessing urbi et orbi, "to the city and the world").
Note optima (plural). The English is short for "the best things of both worlds". The "best thing of both worlds" would hardly make sense as it would just be from one of them.
The standard word for "both" is ambō, which inflects like duō "two", and the most common word I know for "world" (though it was a poetic calque until post-Classical times) is mundus.
So "both worlds" would be mundī ambō. For "the best of…" you would want a partitive genitive, optimum mundōrum ambōrum.