Each period, profit adds to retained earnings and a dividend or some other distribution subtracts. Losses subtract as well. The running total is an accounting stock. It is not a pile of cash. The profits may have been spent long ago on plant, inventory, or the repayment of debt.
A large retained-earnings balance says the company has earned more than it has paid out over its life. It does not say those earnings were reinvested well. That question is return on invested capital and capital allocation.
Retained earnings are one component of book value. Left inside a business that can reinvest at a good rate, they are the raw material of compounding.