Better pain relief for tiny infants has clearly been possible for a long time. For almost 20 years, doctors at some academic medical centers have been safely giving anesthetics to premature babies. And over the past decade, the development of new monitoring equipment, new anesthetic agents and new technologies for administering them have greatly reduced the risks.

A deeper reason for the failure can be found in science, now regarded as faulty, that allowed ill-founded beliefs about newborns to take root. The notion that babies do not feel pain stems from studies in the 1940's indicating that newborns did not respond to pinpricks by pulling their limbs away as an older infant would. Unproven Theories

A wide range of unproven theories was voiced to ''explain'' how this was due to an immature nervous system or other physiologic factors. Today, it is recognized that these studies, and others later, had serious flaws. Now doctors know that infants utter unique cries and secrete high levels of stress hormones in response to pain, and that their pain pathways and brain functions are more mature than previously thought.

The failure to provide anesthesia was also fostered by the fragmentation of modern medicine. The pediatricians and neonatalogists most apt to be concerned about the pain were often unaware that the anesthesiologists in the operating room were withholding drugs. And the new knowledge about infant pain has been slow to diffuse because much of it was published in specialized neurological journals seldom read by the doctors who care for the infants.

Only after parents and other laymen raised a cry about needless suffering, and some filed lawsuits, was there enough pressure to change.

The long failure to provide anesthesia for newborns provides a salutary reminder that medical practices are sometimes based on flimsy science and erroneous beliefs, and that outside critics can bring an important perspective.

Indeed, with the benefit of hindsight, the anesthesiologists who withheld painkillers all those years would probably admit they made a mistake, said Dr. Frederic A. Berry of the Children's Medical Center of the University of Virginia. ''But they were doing it for what they thought were good reasons at the time,'' he said. ''You can question their methods, but not their motives.''