Speculators flocked to buy gold futures yesterday as a combination of factors - mostly negative for the economy - boosted the price of gold to its highest level in nearly three years.

Gold futures scored life-of-contract highs on the Comex in New York, surging $2.80 a troy ounce to $180.30 in the February delivery. In London, gold sold for $179.25 an ounce, its top price since March 13, 1975.

Metal analysts cited the Carter administration's plan to sell military planes to Middle East countries, as well as generally negative economic news, as reasons for the strenght.

Silver and platinum futures also posted healthy gains, with silver advancing about 9 cents a troy ounce and platinum gaining $5.

Meanwhile, coffee futures were sharply lower. Fear that Brazil might reduce prices to large coffee buyers triggered the selling. Most contracts dropped the daily allowable limit of 4 cents a pound. The March delivery, which is not restricted by price limitations, plummeted 5 1/2 cents.

Soybean and corn futures were little changed on the Chicago Board of Trade, but wheat deliveries lost an average of 2 cents a bushel.

The Brazilian government said drought may have cut its soybean output less than 12 million metric tons, 1 million less than some analysts had predicted as recently as last week.

But the report failed to generate as much buying as expected. When a prominent local professional sold large quantities in the soybean pit, the initial advance was wiped out.

At the close of grain trade, soybeans were 1 1/2 cents a bushel lower to 2 1/4 cents higher, with March contracts quoted at $5.65 1/4; wheat was 1 1/4 to 3 cents lower,March $2.66 1/2; corn was unchanged to 1/4 cent lower, March $2.26 1/4; and oats were unchanged to 1 1/4 cents lower, March $1.26 3/4.