DNA has a negative charge and so will move to the positive electrode in an electric field. A gel is a molecular mesh, with holes roughly the same size as the diameter of the DNA string. When an electric field is applied, the DNA will begin to move through the gel, at a speed roughly inversely proportional to the length of the DNA molecule (shorter lengths of DNA travel faster) — this is the basis for size dependent separation in standard electrophoresis.
In TGGE there is also a temperature gradient across the gel. At room temperature, the DNA will exist stably in a double-stranded form. As the temperature is increased, the strands begin to separate (melting), and the speed at which they move through the gel decreases drastically. Critically, the temperature at which melting occurs depends on the sequence (GC basepairs are more stable than AT due to stacking interactions, not due to the difference in hydrogen bonds  (there are three hydrogen bonds between a cytosine and guanine base pair, but only two between adenine and thymine)), so TGGE provides a "sequence dependent, size independent method" for separating DNA molecules. TGGE separates molecules and gives additional information about melting behavior and stability (Biometra, 2000).