If a company makes money, in the form of cash inflows, that money belongs to shareholders. It should not matter whether a company keeps money and invests it. or returns the money to shareholders. This is what is assumed, correctly, by most valuation methods such as free cash flow DCFs.
It is also possible to show that it should make little difference to investors whether dividends are paid or not as investors they can reproduce the cashflows of different dividend policies. For example, if a company pays out dividends, but an investor would prefer the money to be re-invested, then the investor can simply use the dividends to buy more shares.
Conversely, if a company retains too much (from a shareholder's point of view), then the share price will be boosted by the company's stronger cash position, and the shareholder can offset that by selling a few shares.
These arguments for dividend irrelevance are closely related to the Modigliani-Miller arguments for capital structure irrelevance.
However investors do often react to changes in dividend policy for a number of reasons.
One reason for paying or not paying dividends are the tax consequences. What a companies can do to minimise the ultimate tax bill (its own and shareholders' combined) will vary with tax rules and its shareholder base (different types of shareholders, such as individuals and pension funds, face different tax rules).
Tax undoubtedly has an important effect but it is far from being the whole story: companies pay dividends even under tax laws which make it always better, from that point of view, to retain the money. The simple version of dividend irrelevance also ignores transaction costs (the costs of buying and selling shares). If a company follows a dividend policy that suits them, shareholders are saved the transactions costs incurred by mimicking a different policy.
Finally, and most importantly, paying dividends sends signals to the market. Most companies' management do not like cutting dividends. This is why special dividends are used for one-off payments. Therefore, when a company pays a dividend it is showing that the management are confident that the company's earnings will always be sufficient to pay that dividend.
Returning money to investors, whether through dividends or returns of capital, also shows investors that a company is willing to return money it can not invest profitably enough to benefit shareholders. This is, of course, what companies should do but, given that many companies have wasted shareholder's money on empire building (i.e. over-expansion and acquisitions), a willingness to return money is reassuring for investors.
Although dividend irrelevance is not completely correct, it a good enough approximation to reality that fundmental valuation should usually ignore dividend policy. The signalling aspect of the more complete theory suggests that dividend yield is an important measure of management confidence, and therefore can be taken as an indicator of the stability of earnings.