What is the purpose of tiny "bumps" on LED legs?

From here this is what the leadframe looks like.

enter image description here

This is what they look like when they are molded in small scale production:

enter image description here

After this, the parts are separated but the die is made so that it does not weaken the lead, which means it has to be a bit wider in that area. So the remaining nubs are artifacts of the production process, like ejector pin marks on a molding.

Your first guess is correct.

The leads are held together in a strip of lead frame, until individual LEDs and their leads are cut off.

5mm LEDs can be made without flanges from lead frames that attach at the end instead and temporarily held in place during fabrication, then cut to specified lengths after factory separation.

The purpose of the flange is to promote a standoff gap between base and pad soldering @600’F. Without heatsink tools, the soldering heat velocity is 1mm/s along the lead and soldering time must be <5s preferably 3s to avoid heat damage to epoxy moisture seal on the base. Moisture ingress can damage life expectancy from corrosion. Clear epoxy is worse than black epoxy for moisture seals.