How did people transport food before aluminium foil was invented?
A complete answer to this question would require writing a primer on the history of food preservation and transport.  I'm not going to write one.  Instead, I'll focus on the most common methods of personal food transportation -- (that is, snacks, meals, and travel food) in the middle ages.

Transporting foods across the village would have been a daily or weekly event in most medieval European villages, because frequently villages had a common shared oven.  This oven belonged to the baker or to the village council, and after the bread was done, the residual oven heat was used to bake beans, casseroles, pot roasts and other slow-cook dishes.  Generally, the ceramic vessels for such dishes had lids (which were sometimes sealed with flour paste to retain moisture), and transported unopened in a basket.

For road food, one of the most common methods was as pies.  Contrary to modern hand-pies with flaky delicious crust, for many medieval pies the crust was thick, dense, and inedible.  The crust wasn't part of the food, it was a sealed wrapper to protect it (with indifferent success); you broke open the crust with a knife and ate the insides with a spoon, tossing the crust to the pigs or dogs (or the very poor).

Another method of sealing food was "potting", which involved putting meat, seafood, or other foods in a small pot and covering the top with a thick layer of fat or (for expensive dishes) wax.  The potted food would be cooked with the sealing layer on top, and thus survive for a couple of days until bacteria penetrated the protective grease layer.

References:


Bakehouses and community bread ovens (oldandinteresting.com)
Pie Crusts (medievalcookery.com)
Meat Potting (archived from waltonfeed.com) 


Book References (where I got most of this):


Putting Food By
Near a Thousand Tables: A History of Food
Victoria's Home Companion