When you melt cheese, you're essentially softening the milk proteins and fats to varying degrees of pliability and usability. When a cheese is heated, the protein matrix — which trapped the fats and proteins in milk and helped form solid curd when the cheese was made — collapses, encouraging the flow of cheese into a more liquid form.
The way a cheese melts is determined by its moisture content: low-moisture, and therefore normally drier, crumbly, harder cheeses, call for higher temperatures because they have such a concentrated formation of protein bonds that are harder to break down. When they melt, they don't flow in the same way that softer, more pliable, higher-moisture cheese does, which melts at lower temperatures and whose protein bonds collapse more easily.
Furthermore, a cheese that melts more easily, like a higher-moisture cheese, will then melt more cohesively with itself, while a really hard cheese like parmesan will melt as individual shavings, but won't become a melted mass like a semi-hard gruyere or cheddar. Ever heard of a grilled cheese made with a dry, aged pecorino? Probably not.
Stringiness is largely determined by how aged a cheese is as well. A well-established colony of casein (cheese protein) molecules, aged and hardened by the activity of ripening enzymes, is less able to morph into a melted, stringy form. High moisture helps to separate casein molecules, so stringier, more meltable cheeses will often be higher in moisture, but not so high like a mozzarella, that they stick together.
The best melters in the world are a great combination of both age and moisture: Emmenthaler, Gruyere, and Comte, the legendary mountain cheeses and the originators of fondue: the ultimate showcase of how choosing the right cheese for the right application pays off.
Thanks to On Food and Cooking, by Harold McGee, for reference.
Related: In Praise of American Cheese