Then whenever a company needs capital for future expansion - whether it be for secondary stock offerings, new factories, or stock options to entice key researchers or executives - they have an accurate price on the stock with which to judge the cost of capital. If their stock price is low and capital expense is high, they may decide that the capital investment won't increase the value of the company enough to be worth it; the market has prevented capital from flowing to inefficient businesses. (Again, if they guess irrationally, they go out of business, and the system remains rational even if management isn't.) Similarly, if the market puts a high price on the stock because there's a belief that what they're doing is important and will reap big rewards in the future (eg. Tesla), they'll find it cheaper to make big capital investments.
The early-stage startup financing market - angels and VCs - is actually both quite illiquid and quite inefficient - prices at that stage are basically just guesses, which is why some companies rapidly increase in value and many others go to zero. It too depends upon the liquid secondary market after IPO to keep actors rational, though - if VCs could not sell their shares later on the public markets, they would have no incentive to invest in startups.