Both safety and security mean some kind of protection againt an unwanted event. However, they refer to protection from a different perspective.
Safety basically means not to be under a threat or danger. It often related to phyisical safety against bodily danger or any other type of harm. Events endangerign safety usually happen by accedient, against which various types of safety devices are used or actions are taken.
Security also refers to a protection provided by policies and regulations. It also includes intrusion by people, such as burglars or even terrorists. It also means the freedom of doubt, anxiety or fear.
In summary, safety relates to protection ensured by a device and security relates to protection granted by some type of regime, system or operation.
The word safety has a Latin origin (salvus), meaning uninjured, healthy. Secure also comes from Latin (securus) referring to without care, free from.