A valid target is not a requirement to cast a spell
As long as you can designate a target for a spell (and satisfy all the other requirements to cast it, of course), you can cast that spell. The section on spell targets starts (emphasis added):
A typical spell requires you to pick one or more targets to be affected by the spell's magic. A spell's description tells you whether the spell targets creatures, objects, or a point of origin for an area of effect (described below).
You are required to pick targets for the spell, but the targets you pick may or may not be valid. They might not even be the right "kind" of target. To take the example from XGtE's1 section on invalid spell targets, the Charm Person spell targets "a humanoid you can see within range". You might be fooled into casting this spell at any number of non-humanoid targets. The section gives the example of a vampire, who appears humanoid but is actually undead. However, you could even end up targeting things that are not creatures, such as an illusion created by Major Image, or a stone carved and painted to look like a humanoid. As for what happens when you designate an invalid target:
If you cast a spell on someone or something that can’t be affected by the spell, nothing happens to that target, but if you used a spell slot to cast the spell, the slot is still expended.
A spell can be readied without a target
In fact, you don't necessarily need any target at all to cast a spell. Any spell that can be readied can be cast without choosing a target, since the whole point of casting the spell in this way is to ready it to be released later (typically after an appropriate target has presented itself). For example, if you ready a Blight spell with a trigger of "when I see an enemy", you are casting it with no specific target in mind.
Implications for Wish
So, we can bring this back around to your example of casting Wish to duplicate Sequester, targeting the BBEG, who we can presume would rather not be sequestered. Wish will duplicate the effect of Sequester, and Sequester only has an effect when cast on a willing creature. Hence, the duplicated spell has no effect because the target is invalid.
(As always, because you're casting a spell that can potentially do anything, you can wish for the target to be affected even though it is invalid. But this would no longer be duplicating the effect of a spell, so it comes with all the associated downsides of using Wish in this way.)
1It's worth nothing that the rules in XGtE are considered optional, but in this case I would argue that they are mainly just taking the implications of the core rules and making them explicit (do you really need to be told that a spell can't affect an invalid target?), so it makes sense to use them as a default.