What determines how well cheese melts
Three factors influence how well cheese melts:

The amount of moisture,
The amount of fat,
How it was set.

The meltiest cheeses have a lot of moisture and fat and were set with rennet and not acid.
Both moisture and fat leave space between the casein proteins that allows them to move. Otherwise they are packed together and don't flow as well.

Aged cheeses have lost more of their moisture to evaporation. This means that they have to been heated to a much higher temperature before they will melt. 

To quote Harold Mcgee:
"Melting behavior is largely determined by water content. Low-moisture hard cheeses require more heat to melt because their protein molecules are more concentrated and so more intimately bonded to each other." (On food and Cooking, 64).

Aged cheeses with a high fat content will often leak some fat when they finally do melt- making an oily mess. J. Kenji Lopez-Alt had some good suggestions for dealing with this problem.

Acid set cheeses, such as Indian paneer and latin Queso Blanco, don't melt much when heated dry because the acid denatures the casein in such a way as to cause it to bind more tightly.(although they will dissolve into hot liquids sometimes.)