Why do bubbles form and stay when I shake a bottle of tea?
Tea is may be considered as aqueous solution of many different substances extracted from solid tea leaves.  (It is not so much about «tea» as in tea, or a tisane.)
In this solution may be ingredients altering the surface tension of water sufficiently enough that air bubbles are trapped for a prolonged time.  It could be a component added to act as a preservative, which equally happens to act as a surfactant, or an ingredient intentionally added to ease formation and preserve these bubbles; like the tapioca pearls in  bubble tea.
Compounds acting as surfactants may be artificial (like CTAB) made for cleaning, or processes from natural sources, e.g., polysaccharides (like starch), or plain natural.  Washing clothes with leaves of climbing ivy, for example  works because they contain a small amount of saponins.  That a compound acts as a surfactant does not say if it is safe in food, or not.