What is the best and safest way to remove a cyst that is just under the skin?

Be careful. A lot of people will simply squeeze a cyst to extrude the cyst contents. However, this won't actually get rid of the cyst. It may keep it from coming back for a while but it will gradually enlarge. And if the cyst ruptures under the skin the cyst material can really cause a problem. Having it surgically removed is often your best option.
See a dermatologist. Cysts can be removed by your dermatologist. It is a routine surgical procedure. Don't try to remove it yourself!
Surgery Best. A cyst is a pocket or saclike structure in the skin, which usually contains fluid or keratin material. An inflamed cyst can be lanced and the contact drained (incision and drainage). Some inflammatory cysts respond well to corticosteroid injection which can shrink the cyst promptly. But the most definitive way to remove the cyst is with surgery, in which the sac is removed in its entirety.