Cooking potatoes in aluminum foil is perfectly safe. The purpose of the foil is to either reflect the heat or to keep it in. For a time, some people were concerned that using aluminum foil to cook food in was causing Alzheimer's Disease.
But studies have found no conclusive evidence to support that. If you are cooking with aluminum foil, you want to be sure the shiny side is on the inside. This will keep the heat in and it will cook faster.
After you microwave a baked potato, you can wrap it in foil and let it stand for a few minutes. This will keep it cooking inside to be sure it is done all the way through. If you are roasting something in the oven, you can tent it with foil shiny side out, to prevent the food from browning too much.
The foil will reflect the heat away from where it is covering the food. You can also wrap the food in foil to keep it moist inside. Following are several websites that give you recipes for cooking potatoes in foil and other facts about it.