Although gliders can fly for hours before landing, often covering hundreds of kilometres in the process, like everything else they are subject to the law of gravity. Unless the pilot does something about it, his glider will quickly be back on the ground.
Pilots are constantly looking for rising air. If the glider flies in this, it will go up along with it. Once the pilot has gained enough height, he can carry on his route, looking out for the next bit of rising air, or 'lift' as it's usually called. Think of height like the fuel in a car and the rising air like a petrol pump.
There's a lot of energy in the sky and lots of different sources of lift. The three most common ones are thermals, ridge and wave.