legality, not legitimacy.
just because the odds aren't 0% doesn't mean it's not an immediate red flag. a 6IV shiny wild pokemon in S/V that has a mark has absurd odds, or things like having a specific Height/Weight value for multiple pokemon in the party.
just because pkhex says an individual pokemon is "legal" does not mean it will always be viewed as "legal" or truly is. see the latest release, which now flags modified raids.
there are a ton of things that pkhex doesn't look at in detail, as they are not currently implemented.
only way to know for sure is to know everything there ever is about the intricacies of every single game, or write a program to do it for you.