There are rare digestive disorders where most foods cause serious complications. For example, with severe irritable bowel syndrome or certain congenital metabolic diseases, the body can't tolerate proteins, fats, or complex carbohydrates. Cookies and tea in this case work as products that minimally irritate the digestive system and don't contain components harmful to the patient.
The problem is that eating only cookies and tea is critically inadequate nutritionally. The body gets carbohydrates, some calories, and fluids, but it lacks proteins, fats, vitamins, and micronutrients. A person on such a diet will eventually face anemia, muscle weakness, immune system problems, and bone issues. Usually doctors find a compromise: they carefully add other safe foods, prescribe vitamin supplements, or special medical nutrition mixtures.
If the story about the girl is real, it's most likely a temporary measure or the information got distorted in retellings. Living solely on cookies and tea for years makes no medical sense - the body will simply start to fail.