In an isolated TM atom, with nothing around, all d-orbitals are indeed degenerate.
However, the presence of ligands changes that situation.
For example, I take the case of octahedral coordination: 6 ligands around the metal centre. Two orbitals, dx2-y2 and dz2, are pointing towards the ligands and are more destabilised (higher in energy) than the three other orbitals dxy, dxz and dyz which are not pointing directly towards the ligands. So, in this case, the d orbitals are now distributed into 2 groups named:
eg contains dx2-y2 and dz2 which are still degenerate with one another
t2g contains dxy, dxz and dyz which are still degenerate with one another