using tng as basis, the basic premise of star trek is that replicator technology and some kind of miniaturized fusion reactor (replicatable) obviated all capitalistic human labor allowing for a massive de-urbanization on earth. this was after some major cataclysm of resource exhaustion occurred, while not explicitly stated, you can infer that nearly everyone outside of the westernized upper-middle-class (or better) died.  starfleet only exists because humans bullied every other culture they met into joining with the alternative being complete economic collapse.
United States