In many of the Star Wars movies, Jedi come back as Force ghosts.
Why don't they stick around forever, giving advice to new generations, as well as countless knowledge from thousands of years?
Before his death, Qui-Gon Jinn discovered how to "preserve your mind through the living Force" (or something like that) after death. He only managed to stick around as a voice. That's why we hear him scream "Anakin!! No!!" in Episode II when he's avenging his mother.
In The Clone Wars Sixth season (still canon, as far as I know), Yoda goes on a journey to learn the full technique. It's an awesome story arc, right at the end of the series. Then, in Episode III he passes on his findings to Obi-Wan.
It's not a common technique to become a Force ghost.
We rarely see Jedi come out as force ghosts. In fact, it was a lost technique until Qui-Gon Jinn rediscovered it prior to the events of the Phantom Menace. In the legends canon we do see some ghosts who stick around, but it's because it's attached to something like a Holocron. Exar Kun's mentor shows up to help fight him as a force ghost in the Jedi Academy trilogy.
Another legends example of force ghosts sticking around for a long time would be in Star Wars: The Old Republic. There are force ghosts who stay around educating the future generations, but they were mostly bound to an object or holocron.
If we wanted to extrapolate on why they didn't stay around, it could be because they are like our universe's version of ghosts: They have unfinished business. Like teaching Luke, or seeing their mistakes reversed. Also, it could require a great deal of effort to maintain their form after dying, after death the Jedi join the living force.
To summarize: In the main canon, it was a lost technique, so not all Jedi stayed around.
The Jedi who are force ghosts preserve themselves through "the living force". The "living" part is the important part to notice. This could very well mean that they are sticking around due to other Jedi who they had a close bond to when alive(like Luke and Obi-Wan). Their spirits would have been more closely connected that those of two strangers, so the force that flows between them would act like a bond, keeping them here for a period of time after death and before they have completely dissipated from our realm. Like how, when you stick something to your wall, when you pull it off, there is a residue that is eventually weathered away. This is the easiest way of explaining why we don't see force classes with ethereal teachers around the galaxy without straying into legends. Granted, this does involve speculation so I'm not saying that it's technically correct.
When Luke leave Yoda before finishing the training and is about to face Vader, the Obi ghost says something like "I cannot interfere" (you will need to do this alone).
This may indicate that there is some reasons why ghosts cannot interact strongly with the left world. It may the either rule to follow or restriction of the method.
Out of canon. But a Jedi is only one who can appear as force ghost and flows trough patience and the good/light side. The force ghost was actually first ( still out of canon ) Sith or Dark Jedi skill but needed a vessel for the spirit of force and were stored to holocrons or even some cases possessed living hosts.