When online gambling first emerged, it was outside the law pretty much everywhere, so it was kind of a grey area. Not exactly legal, which is why, most sites operated from exotic places like an indian reservate or Cayman Islands. But not exactly illegal either, since there was no specific law against it.
What has happened since is, that governments around the world has moved to either regulate online gambling or prevent it by making laws and enforcing them on operators. As someone else have already said, you can google "Black Friday".
But this is only part of the total picture, since many sites have voluntarely left markets, which are not regulated. Some sites like
partypoker left the US market before Black Friday, and there are many other nationalities, that are also not allowed to play on certain sites. For instance you can read in this forum, that most sites have left the serbian market.
As for those sites still accepting US players, other than from the few regulated states, they are basically breaking US law, which they can only get away with by operating from other countries.
This is not a great situation for players, since it typically mean, that deposit and withdrawals need to be done in creative ways like crypto currency rather than via bank accounts or credit cards. And there is also noone to ensure, that the site is solvent and offer fair games. So its basically a matter of trust, and as a minimum its probably a good idea to not keep to much money deposited on those unregulated sites.