I'm actually surprised that we didn't get a Z for that same reason. 90 % of the work was already done. Making the engine is expensive. Animating all the models, designing buildings, creating textures, writing music, bugtesting everyting, that's where the time and money goes. Making a third version is just scripting, while doing very few new things. I doubt the development costs are even a quarter of what they are for base games. They tend to sell almost as well as the base games, though, so the profit margins should be larger.
Or, try flipping it around. So Game Freak spent a large sum of money creating the XY engine and designing Kalos. Past experience and fan expectations dictate that they could use the assets to create two games (XY and Z - X and Y are similiar enough to be counted as one game), for very little cost. Yet for some reason, they chose to only make one game. They only harvested half of what they sowed, so to speak. Sure, ORAS made very good use of XY's techical prep work, but the Kalos region was under-utilized. The design work that went into XY could have been used again for Z, much like the technical work was re-used for ORAS.