Foil insulation is a radiant barrier, and it works by reflecting heat from the foil surface, but for it to do its job, there has to be a layer of air between the roofing and the foil.
Some types of metal roofing are shaped to create this air space, but if you're installing a type that doesn't, you should construct a batten structure. The foil then goes under the battens.
When sunlight impinges directly on a metal roof, it drives the temperature of the metal as high as 80 degrees Celsius. In the absence of a foil insulation barrier, the underside of the roof radiates all the heat directly into the house. The house overheats, becomes warmer and your air conditioning bill goes through the roof (pun intended).
The radiant foil barrier reflects all that heat back into the air space between it and the roofing. When foil insulation is properly installed, the underside of the roof decking remains at or near the ambient temperature, even in full sun.