Wrapping the ham in foil seals all the juices inside so it keeps it tender and moist so it does not dry out during the cooking process.