What is a stock's value, and why is it valuable?
You own a fraction of the company. Not enough to have a meaningful say in it (though you can generally attend shareholder meetings), but fractional ownership nonetheless -- just because it's a very small stake doesn't make it any less real. There's also no reason why you'd treat a dividend-paying stock differently. If a stock is valued at $10/share and it pays $1/share dividend, then the stock will be valued at $9/share afterward. Before that, you had fractional ownership of a large cash reserve; after the dividend payment, you have some cash and fractional ownership of a smaller cash reserve. Simple as that.
Maybe your question is why anyone would want to own a tiny share of a company. A big reason is that running a company takes a lot of time, and if all you care about is cashing in on their profits, then you might as well invest in stocks and diversify. You give up any possibility of influencing a company's direction, but that may not be what you care about to begin with.
Notably, you don't just realize profits from dividends. If Amazon invests all their money in expanding, then that means their future expected profits are going to be higher (as long as you think they invest the money wisely). You might as well ask why a company keeps investing its money in hopes of making even more money down the road, when they could just stop with the business they have and cash in on their profits (aka turning into cable companies). Paying dividends may actually signal that they don't have opportunities for growth, which may be a bad signal for the future. I'd rather invest in a company that sees opportunities for growth everywhere than one that can't find things to put their money toward and has to send it back to investors.
You can expect to sell stocks to others at any time (because there are always some who will start retirement, and others who will save for retirement -- on top of institutional investors), but that's meaningful for liquidity (the ease of selling) and has nothing to do with where stocks derive their value from. It's not like gold, where the only value is that you expect someone else to buy it from you. It really is backed by ownership of the company.