What are the 'knuckles' on through-hole LEDs and photodiodes for?
I have two possible explanations:


The 'knuckles' are there intentionally to avoid the pins going all the way through the PCB.
Most of the times it is not desired that the pins are going all the way through the PCB.
They are a remnant of the production process (see picture below).
First the pins are a part of one single metal sheet and are cut after the dies and the casings are added. The cutting leaves the knuckles.