Like most things there's a reason behind why something is known by what it is and the word lanyard comes from "lanière" which comes from the French language and translates to "strap". They were first used in the 15th century where French soldiers used a lanière to attach weapons and other belongings to themselves so they can be quickly retrieved when they were in battle.
Not only have lanyards remained in the military for it's original purpose to have an accessible and organised approach in wars, since then it has been developed into the lanyard we know of today where they are straps of material which are still used to keep belongings close by. The belongings could be something like a set of keys as well as more modern (compared to the 15th century) items like printed ID cards or other access control accessories. The lanyard has been developed from what goes around the neck to safety lanyards which are larger and heavy-duty and are used to prevent falls from high places such as buildings.