Forklore: Stuffing stuff
Cooking one food inside another would seem to be one of those obvious ideas. People put a stuffing inside a roasting bird or animal in country after country, and it's the most common thing in the world to stick something into dough before baking it.
Stuffing vegetables is a little less obvious. Leaves, sure--before there was aluminum foil, people often wrapped things in leaves to make a convenient cooking package, and sooner or later they were bound to come up with the idea of making the leaf the focus of the dish, as in stuffed cabbage or grape leaves. The Greeks were making thrion, a dish of fig leaves stuffed with sweetened cheese, thousands of years ago.
The plumper vegetables, like tomatoes and gourds, resemble pots, and that may have planted the idea of filling them. Eggplants were being stuffed in Spain as early as the 13th century.
But it takes a real obsession, like one that developed in the Near East three or four centuries ago, to stuff vegetables like carrots and zucchini (which are hollowed out with a special utensil) or onions. Particularly onions. The layers have to be separated, softened by blanching, wrapped around a filling and finally tied with thread before cooking.