The question as stated now is very broad, with no specific examples.
In an attempt to give a fittingly broad answer, try to find a way to allow the kid to experience some [less severe than life and death] negative consequence that naturally comes out of that action, and if it's that important, see if you can show (videos of?) examples of more severe consequences that might lead to productive vicarious learning...especially if the kid has empathy and seems likely to respond to that.
If it's something like a toddler shoving a screwdriver in an electric outlet, you should also invest in physical barriers like outlet covers or maybe GFCI protection, at least as temporary measures until those dangerous boxes are no longer as dangerous. It is a somewhat invisible danger that can be very hard to understand, especially for young kids, and it's not the only example like it.
Similarly, dangerous objects (e.g. matches, lighters, pills, blades, firearms, explosives, poisons, dangerous chemicals, explosives, power tools, certain hand tools, choking hazard objects, credit cards, etc.) should just be kept out of reach (via some effective access control) until the kid is old enough to understand the danger & permanence of consequences, has been appropriately trained in well-supervised settings, and has demonstrated responsibility with access.