Why is "to" not appropriate before "be" in this situation?

Solution 1:

It might be explained when we write the first sentence like this?

1) "It is better to be <x> than <y>."

2) "Why be <x> when you can be <y>?"

The main verb in the first sentence is the "is" at the beginning. So you do not compare the same.

The correct question to the first sentence would be:

2) "Why is it better to be <x> than <y>?"

Here you have got equal forms.

Additionally the first version left something out. Reading the question we add a bit to comprehend the sentence. Something like:

2) "Why do you want to be <x> when you can be <y>?" or

2) "Why should you want to be <x> when you can be <y>?" or

2) "Why would you like to be <x> when you can be <y>?"

When we look at this versions, we have the "to" before the first be and none before the second, according to

Modal verbs (such as can, must, and may) take an infinitive as their complement, but the to is removed.

as mentioned by dizzwave.