Most people will be stung by a wasp sometime during their lifetime. Few bother to look at the stinger up close. The typical response is to swat or run away.
The wasp stinger is a modification of the ovipositor, the egg laying organ of the female. Male bees and wasps do not sting and can be safely handled (if you can accurately tell the difference). The evolution of the hymenopteran ovipositor into a stinger occurred in the parasitoid wasps. The parasitoids lay their eggs inside other insects. Parasitoids secrete a variety of substances into their hosts that enhance survival of their progeny. These substances include enzymes, small organic molecules and even virus particles. The hypodermic syringe shaped stinger is well adapted to injecting substances into other insects and just as useful for getting under the skin of vertebrates.
In many of the familiar large wasps such as hornets and yellow jackets, the venoms have evolved into defensive secretions. These wasps can sting animals much larger than themselves and drive them away from their nest. The defense is quite effective as people who have been stung will attest.