Building on what Patrick has said, this kind of argument as-is is clearly fallacious, but there are cases in which it could make sense depending on your theory of value. These are cases in which X and Y are the only available options, i.e. there is a dilemma between X and Y. If you must do/have either X or Y (and not both), then it could be reasonable to assert that X is good merely because it is better. The typical version of this claim though, is about rightness and wrongness (normative ethics) rather than goodness and badness (axiology).
Consider a basic formulation of utilitarianism: An act is right if and only if it maximizes utility (by maximizing pleasure and minimizing pain) relative to all other available actions. According to this theory, it can be right to do something that produces far more pain than pleasure so long as it maximizes utility compared to everything else you might do. E.g. if homeopathy and chiropractics were the only two possible methods of treatment for a back ache (besides no treatment), and chiropractics produced less pain and no less pleasure than homeopathy (or no treatment), than you could say that it is right to seek chiropractic treatment for a back ache.
Certain kinds of deontologists could say the same. A moderate deontologist, for example, allows that duties can come into conflict with each other, so that sometimes the right action requires violation of one duty in service of another (see W.D. Ross on prima facie duties). For instance, breaking a promise may be prima facie wrong (wrong unless overruled by other considerations), but it could be the right thing to do if, say, breaking the promise is necessary to save someone's life.
Now this still doesn't save the kind of reasoning mentioned in your question because we need one more step to get from X is the right thing to do to X is not bad. Intuitively, you might want to be able to say: "you should go to a chiropractor, even though chiropractors are terrible." This statement suggests that chiropractics is a bad thing, even if it is better than homeopathy, and even if you ought to support it/seek it out. However, it could be that you have a theory of value on which value reduces to (and is perhaps is explained by) normative ethics. In other words, you might think that something is good if and only if it is right to bring it about/seek it out and something is bad if and only if it is wrong to bring it about/seek it out. E.g. chiropractic treatment is good if and only if you ought to have it. If you thought this, then you could make a version of the argument that was valid (if not sound). Note, though, that it would be very hard to hold such a theory of value as a consequentialist without circularity.
In summary, a valid version of the kind of argument you ask about could look like this:
- It is worse to have Y than to have X.
- We must have either X or Y, and not both.
- So, from 1 and 2, X is the best thing we can have.
- If some thing is the best thing we can have, then it is not wrong to have that thing.
- So, from 3 and 4, it is not wrong to have X.
- A thing is bad if and only if it is wrong to have that thing.
- Therefore, from 5 and 6, X is not bad.
More concretely, suppose you have a chronically dislocated shoulder. Surgery results in a limited range of motion, but not having surgery results in sporadic dislocations and pain. Here is an argument that surgery is not a bad option for you (the use of "wrong" in this argument is prudential rather than moral - https://link.springer.com/chapter/10.1007/978-1-349-05095-6_2):
- No surgery is worse (for you) than surgery.
- You must either have surgery or no surgery.
- So, from 1 and 2, surgery is your best option.
- If some thing is your best option, then it is not the wrong choice to have that thing.
- So, from 3 and 4, it is not the wrong choice for you to have surgery.
- A thing is bad (for you) if and only if it is the wrong choice for you to have that thing.
- Therefore, from 5 and 6, surgery is not bad (for you).