A company is not allowed, by law, to pay as much money out in dividends as directors or shareholders may wish. It may only pay out a certain part of the shareholder's equity.
In a company's accounts the shareholder's equity is divided into several categories. These are shown on the balance sheet. It may only pay dividends out of its retained earnings — dividends have to come from profits, repayments of shareholders' capital require a reorganisation.
This provides a limited amount of protection for creditors. They are assured that a company cannot pay dividends that will reduce its capital below a certain level. Of course its capital may nonetheless shrink through losses.