Stock gives you a legal claim to a portion of the assets of a company, which as you point out, manifests itself quite clearly during a liquidation event like a dividend payment or an acquisition by some other entity. But tt shouldn't bother you that plans for such a liquidation event might not be clear when you buy the stock. What matters to you (and future investors that might buy your shares from you) is that
if such an event happens, you
have to be compensated as a result. That's why your shares retain value.
To take a more specific example, Google has ~$100B of cash on hand, and it does not pay any dividends. Let's just assume that Google is nothing more than a box containing $100B, and you own a portion of that box amounting to $1000. Even though you can't reach your hand in and take out that $1000, it's yours. In the event it gets released from the box, you're the only one that can get at it because of your ownership. And because everyone else realizes that, there's a pretty clear value to that ownership that they would rationally pay you for.
Of course, Google is much more than just a box of money, it is a box of many things, some very intangible (but still valuable). This extra value makes it worth far more than $100B. But it's still a box, and if the value gets released from the box, you're the one who gets it. So who wouldn't pay (at the correct price) for that?