What is eaten as a fig is a syconium: an inverted flower cluster enclosed in flesh, with a single tight passage called the ostiole. A pollen-carrying female wasp pushes into that passage, and the fit is so tight that her wings and parts of her antennae break off. She cannot leave, and does not need to.
Inside, she pollinates the florets and lays eggs into some of them, which develop into galls. Her offspring mature within the fig. Wingless males emerge first, mate with females still in their galls, and chew an exit tunnel; the females load up with pollen and fly out to find another tree, often over remarkable distances.
Edible figs sold commercially are usually the common fig, and most cultivars grown for the market are parthenocarpic: they ripen without pollination and contain no wasps. Where caprification is used, as with Smyrna-type figs, any wasp that dies inside is broken down by the fruit's ficin enzymes. The idea that every fig contains a whole insect is wrong.
