Border Force Officer here.
Section 55 of the Borders, Citizenship & Immigration Act 2009 says that we must carry out all our functions in a way that safeguards children. Obviously the most important thing is stopping children being kidnapped and/or trafficked (and I've encountered quite a few over the years)! So you might be asked questions leaving or entering the UK (probably more likely to be when entering, just because there aren't always exit checks).
We are trained to assess certain situations so I won't always ask for documentation if I've asked a few questions and I'm satisfied that the child is travelling with their parent or guardian, and is happy to do so.
If I do ask for a permission letter I would be happy with a quick squiggle saying "I give permission for xx to travel with xx", but I would also hope to see a photocopy of that person's passport to prove it's written by them and a contact telephone number in case I want to confirm any details.
Obviously you get good and bad Border Force Officers. Some of the bad ones will not even bother asking anything, while some will interrogate passengers unnecessarily and incorrectly say that passengers MUST produce documentation. Please feel free to lodge a complaint against any bad ones you encounter!
To confirm, it's not compulsory to produce something but it makes things easier if you do. I carry a photo of my children's full birth certificate on my phone as they have their dad's surname.
Hope that helps.