What determines whether you get burned or not is not the temperature. It is the total amount of heat. Aluminum foil (they don't make tin foil anymore) is very thin. So, it cannot store much heat. Therefore, when you touch it, what heat it does contain is dissipated before it can burn you. However, the pan is made of much thicker metal than the foil is. So, it can store more heat. So, when you touch it, it has more heat to transfer to you, thus causing a burn.