Hey there! First of all, it depends on what you mean by 'legal'; if you mean are the Pokemon obtained in this way are legitimate, then sadly they are considered hacked for all intents and purposes. If you mean 'is it LEGAL legal', then honestly I'm not too sure myself. I think that it's definitely a gray area, as once again you are using outside means to create or modify things within the game. It's about as 'legal' as any other method of hacking the game.
One point that I don't think enough people are aware of is that the DNS method of obtaining hacked event Pokemon is actually very risky. If the DNS server you are connecting to isn't secure or is actually run by a malicious party intending to bait people with 'free' events, then it's as good as opening your front door and giving a burglar the key to your secret basement full of valuables. It provides a VERY easy gateway to get your device hacked and potentially your saved credential and financial information stolen, so I would highly suggest to avoid this method of hacking.
Your best bet of course is the good ol' fashioned way; trade with people who already have the events you need! There is a plethora of veteran traders who were around for those older events, and it's even easier than ever to trade for them as cloning becomes more acceptable and trading online has become easier than ever.
Just want to say, the stuff regarding the risks of DNS modification is not wholly accurate. A DNS server is as it's described on the tin - a "dynamic name server". As in, you tell your computer to go to google. Your computer reaches out to a known destination (a dns server) and says 'hey my user with all their language and words and stuff is looking for this thing called 'google'. Where the heck is that?!?'
From there, the dns server spits back an actual network address and routing info, telling it where to go to actually reach the devices which contain the information we would recognize as the google website. So at that point in the exchange, your computer has not given the dns server any more access than it would say pokecommunity, or any website you visit. A transactional exchange of information occurs, but you're not downloading any files from there, providing any credentials, or anything like that. So the risk is very, very minimal.
The area where risk occurs, is if the sites it directs you to are not legitimate. If you say you're going to google, and it spits back an address and routing info for a machine Pretending to be the google website, when you 'sign in', you've provided those malicious individuals with your google account info and password, allowing harm to occur. Things can escalate quickly from that point, but the lesson is simply this: If you are using questionable DNS info, assume *every* site is fake. Do not go to your bank, or anywhere you use a secure password. Do not sign into anything, and under no circumstances should a transaction be made. Just go to the place you need to go (the site which isn't listed on standard dns), do what you need to do, and then get out and fix your DNS.
Also one more note: If you are told ever you need to modify your DNS to access a site, that's really only partially true. If a site is unlisted, generally you can still get there with its IP address. After all, that's the whole point of a custom DNS, is to allow you to put in common words and get back the actual IP address you're going to. Barring some tricky routing schemes, generally speaking once you get where you want to go, you can open a Command Prompt, ping the website (type in "ping X" and press enter, where X is the website you went to) and it'll show you what the actual IP address is. In the future, rather than change your DNS, try just putting in that IP address and you should hopefully be good to go.
I hope that info helps! Sorry couldn't help but jump in since computer stuff is kinda my thing :-)
A question that I have: I'm getting ready to catch Red Gyrados in HG. I am not into shinys myself, other than as trade bait. My main goal is to get as complete of a National Dex as possible, so I'd be bringing it forward into Home and seeing if anyone has interest in trading it for something I need (like a legendary or mythic or event pokemon or something). To maximize its trade value, what should I catch it in? A Luxury Ball, since it's the best ball, and doubles friendship gain for the recipient? An Apriball, like the Moon or Lure Ball? Something else?
Thanks!