Not at random. Most 401Ks are in a fund that carries significant portions of the S&P500.
And though there are "rules" for inclusion, the board has the final say of who is in and out.
The S&P500's growth, however, is linked more with inflation than 401Ks themselves, which inflation also impacts.
...