If it originates from Gens 3 through 7 (SM/USUM) and Virtual Console, it's easiest to generate them in Gen 7, and then send through Bank and HOME to ensure HOME has the correct data.
If it originates in GO, and is LGPE compatible, generate it in LGPE, then send to HOME.
(If it isn't LGPE compatible, there's no game you can generate it in where HOME will have 100% correct data for it, and you cannot inject directly into HOME or GO, as both are server-side games that cannot be manipulated.)
If it originates from SWSH, generate it in SWSH, then send to HOME.
If it originates from BDSP, generate it in BDSP, then send to HOME.
If it originates from Legends: Arceus, generate it in Legends: Arceus, then send to HOME.
If it originates from Scarlet or Violet, generate it in Scarlet or Violet, then send to HOME.
If it's a HOME gift you directly redeem in HOME, there's no way to generate these where they appear 100% legal in HOME, since HOME itself is doing the generation.
TLDR, if you want HOME to have the correct data to ensure it appears 100% legal, it has to enter HOME from the "game HOME expects it to enter from for the first time".