The only reason a foreign student needs to be physically in the US is to go to classes.
If there’s no need to be there physically, the rationale for their entry evaporates. Think the legal term is “extinguished”.
Since visa overstays and work without authorization becomes a problem with such alien students, the rule is completely justified, and entirely within the scope of the President’s power regarding “classes of aliens” who can be prohibited.
H1B forums are chock full of filthy Indians hacking every plot known to man to stay in the US. Including enrolling in online schools.
The DOJ busted a few fake Indian colleges in the US, In which tens of thousands of Indians enrolled to come to the US.
An older article, but it checks out. There are plenty of other fake Indian school scams: