The Clone Wars episodes 'Voices', 'Destiny' & 'Sacrifice' dealt most directly with this. But in a nutshell it involves a technique to preserve one's individuality upon death. It was taught to Qui-Gon first, but his training was incomplete and so he was only able to communicate with Yoda as a disembodied voice, not appear as an apparition. This however was enough to put Yoda on the path to finishing what he started.
Then as we glimpsed in RotS, Yoda taught Obi-Wan how to commune with Qui-Gon and do the same. It's not directly addressed how Anakin also managed this, though it's been suggested he had help from the other side.
The beings who taught first Qui-Gon and then Yoda are referred to only as the Force Priestesses. Their true origin and nature is still a mystery and may all in fact be one single ancient being that achieved this physical transcendence long ago and appears to have split into it's constituent aspects.
As for the criteria for who receives this training, it seems to be up to the Priestesses to judge who is worthy of it. Being a Jedi doesn't appear to be a necessity though, since that's only one very specific doctrine that centres around the force among a great many others over the ages.