Adding on to Senjumommy Senpai's answer:
Another aspect to Flutter Mane's viability is Sun. Sun is a very prominent weather, especially in Ubers due to Koraidon, and Flutter Mane can use it to snag a free stat boost, effectively widening the BST gap between it and Gengar. In contrast, Gengar's ability does nothing to help it, at best leaving a parting gift when it faints from a move like Knock Off. Flutter Mane can also stack damage boosting items inside Sun to bolster its damage even more, or effectively give two stat boosts simultaneously. For example, Mane's go-to item, Specs, gives it a damage boost, while Protosynthesis can boost its Speed inside Sun, allowing it to outspeed literarily the entire unboosted Ubers tier.
Flutter Mane also has 135 Special Defense, a stat many forget about until they try to knock it out with a somewhat strong Special attack, like Lunala's Meteor Beam, only to realize it doesn't even come close to OHKOing it. This forces the opponent to respect the stat. For example, Lunala can't grab the Special Attack boost it wants from Meteor Beam against Mane, forcing it to knock it out with Moongeist Beam and thus losing the Special Attack boost. Compare this with Gengar, who is knocked out from the same attack 93.8% of the time, and you start to see how significant Flutter Mane's Special Defense may be. (Both calcs are done with no bulk investment.)
As to why Gengar is in RU and not a higher tier, its Speed makes it lose out on a lot of big threats above. In OU, good luck outspeeding and dealing with Dragapult (which is the whole reason Gengar fell out of OU in the first place imo), Roaring Moon, and physical Iron Valiant, while having to deal with Sucker Punch everywhere from the likes of Kingambit. Sure, Gengar can run Scarf or Substitute, respectively, to alleviate the aforementioned problems, but that either cuts into flexibility or Gengar's already limited moveslots. In UU, Focus Blast is mandatory for Tyranitar, not to mention the other Dark types in Weavile, Lokix, and Greninja, all of which outspeed Gengar and/or have priority. In sum, the existence of Dragapult of a faster Ghost type, the plethora of Pokemon that can outspeed it, as well as Sucker Punch being everywhere makes Gengar not viable in OU or UU.