McGregor showed up with fans and hype, as well as did a lot on his own to cultivate his image. Same with Rousey (or maybe her mom...). Zuffa didn't just give their support to some nobodies and get a massive return on their investment. They had to have something worthwhile in the first place. You also can't ignore their ability and accomplishments in the cage. If the investment and support from Zuffa or now WME mattered that much, UFC would never be hurting for a draw.
UFC was ripe and waiting for someone like McGregor. UFC fans by and large aren't honorable martial artists or high-brow people, so McGregor's shtick was always going to be a hit with the people who liked the trash talk of Tito and Sonnen or pro-wrestler freakshow of Lesnar, or enjoy the general "car crash TV" aspect of MMA. I mean, the sport in the US as we know it is a result of a show featuring a bunch of fighters getting their MTV on with audience retention from WWE RAW. For the most part, we're not talking about people who care about "real" or anything serious.
But yeah, of course UFC only sees money. Make money first, make MMA second. That's what they've always been about and always will be about. McGregor recognized that, seeing the chance to make a star of himself and get paid, capitalizing on it like nobody else could.