Uncooked cheese contains long-chain protein molecules more or less curled up in a fatty, watery mess.
When you heat cheese, the fats and proteins melt and if you fiddle with the fluid, the chains can get dragged into strings.
Grab a bit of the molten cheese and pull, and you get a filament, in much the same way that you can draw and twist cotton wool into yarn.
You can do similar things with polythene from plastic bags by heating or stretching the plastic to curl or stretch the long-chain molecules. When the molecules are curled up, the plastic is softish and waxy.
When they are stretched into fibers, the result is elastic and strong in the direction of the stretch, although it splits easily between the chains lying along the fiber.
As the cheese melts, the long-chain protein molecules bind together to form fibers in the liquid mass of melted cheese. It is believed that this characteristic can actually be used to measure the protein content of a cheese sample directly.
A string of cheese is pulled away from the sample, and the distance to which the fiber will extend away from its attachment point on the main piece of cheese is measured against some reference sample of known protein content.
In the end, all that matters is long strands of stringy cheese make eating pizza or a grilled cheese sandwich much more fun.