To begin with, trash bytes don't serve any purpose (hence the word trash in the name)
One example of it happening in some games (maybe for all, I don't recall) is when something with a longer name, evolves into something with a shorter name.
So for example, Chikorita -> Bayleef
In reality, the name is now Bayleef/a, where / is the terminator in this example.
The game just replaces the minimum amount of the name, then tags on a terminator. everything else isn't erased, but not visible in game, effectively becoming 'trash'.
In older games, you could trade a Pokemon to another language'd game and evolve it there, and it'll get that nickname upon evolution.
So in Chikorita's case, it becomes 베이리프/rita
HOME may not necessarily be checking specifically the trash bytes, but rather making sure the entire nickname region doesn't have a mix of impossible characters, and the trash byte being part of the region, got detected. I can't say for sure.
But yeah, while trash bytes wasn't generated by the game on purpose, and isn't used, as per anything else in a Pokémon's data, it can be used for hack checking