Is there any recommended day to leave the UK before your visa expires? Should you leave 5 or 10 days before the visa expires?
You can leave however many days before the visa expires as you wish, provided that you don't overstay your visa or the "leave to enter" stamp in your passport.
However, when you applied for the visa, you provided an itinerary. If you apply for a UK visa in the future, the officer will look at your immigration history, and discrepancies here may pose a problem. For example, here's a question where someone was refused a visa in part because they previously stayed significantly longer than they stated on their application. A significant variation from your application could result in problems at the UK border as well. As such, it's best to stick to substantially the travel plans you provided in your visa application; your visa should have been issued for a sufficient length to accommodate them.
In addition to Zach Lipton's answer, you should also consider the possibility of unforseen delays. If you plan to leave on the last day of your visa, and end up delayed, you may get into trouble.
If the delay is for circumstances beyond your control, and you can prove it, then you'll probably be OK (see What happens if I miss my flight on a 1 day visa in UK?), though inconvenienced. If you can't prove that it's beyond your control, you'll be considered an overstayer with serious implications.
Leaving a day or two early will help prevent such situations.