At this point, the official inclusion of Type: Null/Silvally as Legendary Pokémon implies that the only real criteria there is for Legendary Pokémon is the word of Game Freak/The Pokémon Company. It used to be pretty cut and dry, but these days Game Freak seems to love shaking up the status quo, and because of that, for better or for worse, we have Pokémon like Silvally that break nearly every traditional "rule" about what makes a Legendary, and yet are still explicitly named as such. Yes, it's arbitrary, but it's the truth of the situation.
As much I want to agree with you that Mew and Celebi should be considered Legendary Pokémon, ever since Gen V, The Pokémon Company has been treating event exclusive Pokémon as being completely separate from Legendary Pokémon, hence the term Mythical you've probably seen people use.
Well, first off, it's just coding. Code in a game is never meant to be public. We weren't supposed to know this code exists, therefore it wasn't meant to have any in-universe consequences. The likely explanation is that Game freak wanted to give Ultra Beasts there own classification in the coding as special Pokémon, but realized that whatever this Ultra Beast class was needed for is exactly the same as what the "sub-Legendary" class was needed for, so they combined the two together for simplicity's sake. Things like that happen a lot in programming.
The green background very easily, and at this point, probably does, mean a special Pokémon, not a Legendary Pokémon. Legendary Pokémon are special, so they get the green, but Ultra Beasts are also special, even though they're not Legendary, so they get it too.
I used to think that Ultra Beasts could possibly be Legendary Pokémon, but then Ultra Sun and Moon happened, and pretty much confirmed that there's no way Ultra Beasts are Legendary. It did so in two ways. You can literally catch as many of each of the original Ultra Beasts as you want, which is something they would never let us do with Legendaries, and then there's Poipole. There's no way that thing, even once it evolves, could possibly be considered Legendary. Just look at it's Pokédex description. It's basically called the Starter Pokémon of Ultra Space. Ultra Beasts are just a special, but non-Legendary, sub-category of Pokémon.