What is the benefit of a tinfoil packet?
The packet keeps in most of the moisture, and also changes the way the food is heated - less radiation and convection, more conduction. These two factors change the taste of the food. It gets better heated throughout, less browning, and on the whole, it is more similar to what cooks call "wet heat" than "dry heat" despite being in an oven. This is what makes "packaged" recipes culinary different from the same food, simply roasted. It used to be even more important back in the age of wood fired ovens, which gave much less even heat. Note that tinfoil is just one of the options - you can wrap in other inedible substances like banana leaves, or edible ones, like making dolmas or meat pies. 

A second very important difference is the matter of presentation, taking a piece of wrapped food gets perceived differently than taking a few spoonfuls of roasted vegetables out of a pan. Many en papillote preparations are more aesthetically pleasing than the ones that use tinfoil, but even the foil ones are, if not prettier, at least different. 

Then you get into edge cases like the problem of baking a lump of cheese without losing all the fat, and so on. But for most foods, open roasting is an option, and wrapped roasting gets done because it is a different option, not because it is how it has to be done.