Most of the cartridges you don't hear much of any more were not designed with mass market or military/police use in mind.
These were designed to fill a niche, and because theres such an overlap in capability of the more common cartridges fewer and fewer found it necessary to go to a purpose designed cartridge to fill that niche.
The .40 is not that well suited to compact SMGs, and so long as those weapons have a place in the military/police armories the 9X19 will have a home.
Its low on the totem pole when it comes to effective stopping power with FMJ bullets, but it always has been compared to the .45 ACP, with penetration being its long suit.
Easier mastering of the 9mm pistol by the greatest number of potential users is another factor in its favor.
From what I've heard from a Scandinavian reservist veteran who trained in part with the .45 ACP during the cold war, they had a harder time hitting anything with the 1911 than with any of the available 9mm handguns. That seems to be the norm, with the 1911 being a specialists weapon of choice.
I expect the same would be the case with the .40 if it were a military issue weapon.
The 9mm and the .45 ACP both have four times the history of the .40, and both have seen far more cartridge designs fade from view in that century plus.