Rather than focus on the particular Executive Order, I will consider the general grounds on which an XO may be unlawful.
Federal jurisdiction
First, it must deal with matters that are properly within the power of the Federal government. An XO that deals with matters that properly belong to individual states would be unlawful. This applies to all lawmaking powers of the US government, not just XOs.
Legal source of Power
In theory, the three arms of government have the following roles:
- The legislature (Congress) makes laws
- The executive (President and Cabinet) administers laws
- The judiciary (Courts) resolve disputes about laws.
In practice, things aren't that clear cut:
- The legislature also administers laws (by deciding how to administer its own operations etc.) and decides disputes (through impeachment processes etc.)
- The executive makes laws (by promulgating regulations and XOs etc.) and decides disputes (in administrative tribunals etc.)
- The judiciary makes laws (by interpreting what the laws mean) and administers laws (by deciding how to administer its own operations etc.)
Getting back to XOs, the President must have a legal basis for exercising this power. This can come from:
- A specific grant of power in the Constitution (there are surprisingly few of these)
- A referral of power from Congress, that is Congress has passed a law which delegates the decision to the President. Note that a law that delegates the decision to, say, the Secretary of State, is not a power delegated to the President and would not serve as a basis for a legal XO from the President even though the SoS serves at the President's pleasure.
- A basis that falls to the Chief Executive (President) from common law. That is, something that flows to the head of state from the original English law upon which US law is based (as modified and interpreted by judges) - something Congress could make a law about but hasn't. This is dangerous territory for a President as a judicial decision could mean that the President does not in fact have the power they think they do - that power lies with someone else.
Content
The content of an XO must stay within the boundaries of the legal source of power, basically, it cannot go against any pre-existing law. If congress or the courts have decided that the law is X, an XO cannot say that it is Y. An XO can, however, change the law made by a previous XO by the same or another President, just as Congress can repeal or amend legislation and the courts can go against judgments that they previously made (at at the same or higher level of the court hierarchy).