TO HEAR Mrs. Olson or Robert Young or Vivian Vance tell it, you'd think that the quest for the perfect cup of coffee ranks right up there with the search for the Holy Grail. According to those who tout the ever-popular brew, one's social standing is directly linked to his ability to produce a breathtaking cup of java. You've seen the ads: A neighbor pops in one afternoon for an impromptu Kaffeeklatsch. The protagonist smiles cannily and plucks a jar of instant from the kitchen cabinet. Next scene, and the two coffee-lovers are inhaling deeply from their cups, savoring every sniff. "Fresh-brewed?" exclaims the dumbfounded visitor. "You didn't!"

"I didn't!" crows the hostess. "It's -- instant!" (and she names a well-known national brand). The neighbor's face lights up; she eyes her friend admiringly, as if to say, "Now THERE'S one smart housewife!" In The Beginning . . .

It's said that a humble Arab goathered discovered the stuff. It was 850 A.D. -- or thereabouts -- and the young Kaldi was making his afternoon rounds when he came upon a flock of full-grown animals who were cavorting like kids. As the goatherd soon discerned, the euphoric goats had been noshing on red berries from a wild shrub. Naturally, the intrepid Kaldi plucked a handful of the fruit from the bush and downed them. It wasn't long before he joined his animals in their pastoral romp. And -- if legend is to be trusted -- our love affair with the coffee bean was duly launched.

Kaldi's fortuitous discovery didn't remain secret for long, of course. Some say that it was a monk who spread the word -- a sneaky sort who had chanced to observe Kaldi and his lighthearted comrades and divined the source of their bucolic pleasures. This unheralded soul devised a method of drying and boiling the bean to produce a liquid with the near-miraculous capacity to keep him and his fellow friars awake during lengthy religious rites.

Coffee-drinking soon became a full-fledged custom in the Middle East, although more pious priests banned it as an intoxicant (perhaps because they sought to keep its delights to themselves). But from the moment they were discovered, the scarlet berries were associated with rich visions of religious and ecstasy and earthly exhiliration; devotees of the drink found it heady, exotic, compelling. Religious elders who condemned coffee were hard-pressed to persuade their errant flocks not to indulge in the substance; the rebellious masses apparently agreed with the devotee who wrote that coffee "quickens the spirit, makes the heart lightsome, is good against sore eyes, excellent to cure the gout, dropsy and scurvy . . . "

After doctors took to prescribing coffee (presumably as a hedge against the aforementioned maladies), the drink gained a degree of respectability. The conservative priests were forced to abandon their anti-coffee campaigns. The Arab elite -- scholars, lawyers, artists and the like -- filled the coffeehouses that blossomed in Mecca (and later in all the major Arabian, Egyptian and Persian cities). These gathering places -- headquarters for music, gambling, gamboling, politicking and heated debate -- were prototypes for the great European coffeehouses of the 17th and 18th centures.

But coffee drinking was not confined to public establishments; it moved into Arab homes, as well. An elaborate coffee ritual (similar to the Japanese tea ceremony) gradually evolved. The brew became so respectable -- and so popular -- that the Turks decreed that a wife whose husband failed to supply her with a sufficient cachet of the beans could summarily divorce the cad.

The newfound stimulant was gradually introduced into other parts of the civilized world. Coffee beans were brought into the Balkan states, Spain, north Africa and other areas during the 11th- to 16th-century Muslim expansion. (The converts were undoubtedly as enthusiastic about the Islamic drink as their newfound religion.) French, Italian and English travelers who visited the Middle East in the late 16th and 17th centuries were fascinated by the substance, which was believed to have considerable medicinal powers. Soon the Europeans began to demand shipments of the Arab-grown beans, and multitudes on the Continent became addicted to the novel concoction.

Although coffee has been warmly received throughout most of its history, it has had its detractors; the Islamic priests, 17-century religious fanatics, European and Middle Eastern royalty, and physicians, among them. Some objected to the drink's alleged mind-altering effects. Others claimed that coffeehouses lured the faithful away from the mosques. Most of the rulers who tried to banish coffee from their kingdoms believed that their subects were being destroyed by the drink. As Frederick the Great declared: "It is disgusting to notice the increase in the quantity of coffee used by my subjects . . . If possible, this must be prevented. My people must drink beer. His Majesty was brought up on beer, and so were his ancestors, and his officers. Many battles have been fought and won by soldiers nourished on beer, and the King does not believe that coffee-drinking soldiers can be depended upon to endure hardship or to beat his enemies in the occurrence of another war."

He may have had something there. Vital Statistics

One five-ounce cup -- the standard coffee measure -- contains protein, carbohydrates and fat. But not much: only three-tenths of a gram of protein, eight-tenths of a gram of fat. All in a piddling five calories. You also get a miniscule amount of thiamin, niacin, riboflavin, calcium, phosphorous, iron and sodium in the unadulterated coffee bean. (Who says the stuff's not good for you?)

America imports more coffee than any other country -- about a third of each year's world supply. The runner-up is West Germany, which imports about six million 132-pound bags each year. Next is France, with 4.3 million, and Italy, with three million.

About 3 billion pounds of coffee are shipped into the United States every year. Americans use 13.8 pounds per person annually, 450 million cups per day. Coffee is the nation's most popular drink.

Still, coffee drinking is on the decline here. In 1962, America's per capita consumption was 3.12 cups a day; in 1976, it was 2.2 cups. Bad news for the dozen countries whose principal commercial crop is coffee, particularly in Latin America, which provides about three-fifths of the world's supply. (A fourth of the world's coffee beans come from Brazil; 12 percent, from Columbia. Twenty-five percent are grown in Africa, and a tenth in Asia and Oceania.)

About one-fourth of all coffee is now bought in the form of instant, or soluble, brew. Twenty years ago, soluble coffee accounted for only a tenth of the total consumption. But Does It Cause Cancer:

Coffee has been accused of a multitude of sins and credited with almost as many virtues. It celebrated pharmacological component -- the one which garners both praise and criticism -- is, of course, caffeine. Caffeine is a bitter white alkalois; a powerful xanthine stimulant which acts on the central nervous system. As any habitual coffee-drinker can attest, the substance is psychologically -- if not physiologically -- addictive. The typical cup of coffee contains from 100 to 150 milligrams of caffeine; caffeine which, if some researchers are to be believed, may play a role in the development of heart disease, cancer of the urinary tract and bladder, ulcer, diabetes and caffeinism (a disorder whose symptoms include weight loss, insomnia and loss of appetite). or which -- if one gives credence to other scientists -- is not only innocent of such charges, but may also improve the performance of the mind, sharpen the senses, reduce reaction time, cure headaches, heighten the effectiveness of anti-cancer drugs, calm the restless hyperkinetic child and counteract the effect of barbiturates.

The most recent research tends to disprove the direst claims about caffeine. A 1973 Boston University experiment conducted by Dr. Hershel Jick seemed to indicate a statistical correlation between heart attacks and the consumption of coffee; but later, better-controlled studies showed no such association (and proposed that variables such as smoking could have skewed Jick's results). Dr. Philip Cole, who supervised a 1971 Harvard study which implicated coffee in bladder cancer, finished a more carefully designed experiment in 1975; it failed to duplicate his original findings, and indicated no difference in the incidence of cancer between light and heavy coffee drinkers. And a recently released five-year study of 2,500 people in Evans County, Ga. (where there is a high rate of hypertension), exonerated coffee altogether: It showed no statistically significant difference in the death rates of those who drink a great deal of coffee and those who indulge only occasionally.

Although there is no conclusive evidence that coffee triggers serious degenerative diseases, concern about the effects of caffeine still lingers. Coffee can precipitate notable physiological changes, including elevations in heart rate, body temperature and blood pressure, as well as psychological manifestations -- jittery nerves, anxiety and the like. But research indicates it takes about 10 cups of the beverage to provoke serious symptoms such as ringing in the ears, hallucinations, severe anxiety and irregular heartbeats.

Those who are disturbed by the controversy can take comfort: There's always decaffeinated, which has 2 milligrams of caffeine per five-ounce cup. It's also reassuring to remember that, so far, no one has succumbed to an overdose of caffeine, which would require than 10 grams (or the equivalent of 100 cups of regular coffee) accumulate in the body simultaneously.

"I think coffee is probably safe at the levels at which most people consume it," says Dr. Stephen Kreitzman, Emory University nutritional biochemist. "I'd be inclined to say that there would be more risk from the water used to brew it than from the coffee itself." Instant Coffee

The first known reference to this much-maligned innovation came in 1838, when the United States Congress replaced rum with soluble coffee in rations for its armed forces. (Undoubtedly a wise move, despite Frederick the Great's words about coffee-drinking fighting men.) Eighteen years later, Gail Borden, who gave the world evaporated milk, was awarded a British patent on a milk-and-coffee extract -- a nifty invention which, alas, failed to survive in its original form.

In 1903, Japanese chemist Dr. Sartori Kato received a U.S. patent for "coffee concentrate," which he had sold at the Buffalo Pan American Exposition in 1901. George Washington (a Guatemalan) topped Dr. Kato by introducing instant coffee to the mass American market. World War I gave the product a tremendous boost: The government requisitioned all of Washington's stock and sent it to the doughboys overseas. By the end of World War II, instant coffee was entrenched in the hearts -- and the palates -- of the American public. Today, every fourth cup consumed in the U.S. is prepared from instant.

The process of rendering coffee beans into soluble form involves gas foamers, vacuum chambers, extraction batteries, vibrating coolers and other torturous-sounding implements. First, the coffee is brewed and rebrewed. A vat is brewed from purified water; its contents are dumped into a second vat, where they are brewed with more coffee. The mixture gathers strength as it goes through a series of such extractions. Powdered instant is produced by blowing the extract onto a heated surface, which causes the mixture's moisture to evaporate. The dried substance is then crushed into fine powder. The coarser instant is produced when the extract is forced, via sprayer, through a hot air current, which draws moisture from the liquid. These beadlike particles are spraydried into tiny hollow balls which are ready to dissolve in a cup of boiling water.