In general, the value of a company is determined by the "expectation of future dividends".
If someone sets up a company that sells $2 widgets, that cost $1 to make and they sell 1,000 of them per month, the company is receiving a revenue of $2,000 per month, with expenses of $1,000 per month.
The $1,000 that is left is profit, which could be given to shareholders (the owner(s) and investors) as a dividend, or reinvested (e.g. to buy tools and staff so they can make and sell another 1,000 widgets per month).
The investors can either keep their stake in the company or sell it to someone else. What someone is willing to pay is based on the potential future profits, and the likelihood that the company would succeed in making such a profit.
While investors may buy shares in a company to sell on further down the line, it all has to come back to whether the company will eventually make a profit. Early startup investors may find that the value grows much more initially when the company is risky, so want to get the capital back to invest in another high risk high growth venture, while other investors may prefer to invest in a company that has actually made profit and are less risky, but at the end of the day, it comes down to the question "will this company pay its investors a dividend in the future?"