When you make a profit (or a loss) as a company during your financial year and don't distribute all of that profit (you can't distribute a loss) to your shareholders, the amount left over is called retained earnings. Remember this dates back to all of the profits (or losses) since the business began.
What's included
All of your brought forward earnings.
For example, if your business is in its fourth year and had the following retained earnings (with no dividends to shareholders) in each year:
Y1 - £9,000 profit
Y2 - £3,000 loss
Y3 - £10,000 profit
The retained profits brought forward would be £16,000 at the start of the businesses fourth financial year.
What's not included
Dividends are recorded in to a separate equity category, as these reduce the amount of retained earnings the company brings forward each year.