When exporting an image from Lightroom 5 there is a box titled resolution. The resolution is the physical size of the image and while you can control this, there is also a box to change the PPI. The PPI however does not relate to the image but to printing and changing this number in Lightroom prior to export has absolutely no effect on the image whatsoever.
Can someone explain what it's for please?
Sounds like you explained it perfectly. You are correct, the resolution of the photo is the size of the image in pixels.
About the only time you need to set the PPI number is if you specify the size of the image in inches or centimeters, then the PPI number is used. If you set the size of the image in pixels, this number is not used (even though you can change it via the box) and is meaningless.