The Soviet Union and Brazil signed their first comprehensive trade package today, including large-scale Soviet purchases of Brazilian soybeans and a contract for sharply increased Soviet oil deliveries to the military-ruled South American nation.

Officials here estimated that the value of the five-year agreements would exceed $6 billion. Total Soviet-Brazilian trade last year was about $380 million.

The new accord symbolized continued restructuring of Soviet food imports since the imposition of a ban on American grain exports to the Soviet Union 18 months ago by the Carter administration in retaliation for the Soviet invasion of Afghanistan.It was lifted by President Reagan April 24.

In the meantime, however, the Soviets have mounted a major effort to diversify their food import sources and have sought closer economic ties with two conservative Latin American governments.

The Soviet Union recently has concluded agreement with Argentina to import about $1 billion worth of Argentine meat during the next five years. During the 15-month U.S. ban, Moscow quadrupled its purchase of Argentine grain and oil seeds to a total of almost 8 million metric tons in 1980.

Moreover, ignoring its earlier distaste for the Argentine military rulers, Moscow has exchanged military delegations with Buenos Aires and reportedly has worked out a program for training Argentine military personnel here.

Under the agreement signed today by Brazilian Economic Minister Antonio Delfim Netto and his Soviet counnterpart, Nikolai Patolichev, Brazil will sell a minimum of 25 million metric tons of soybeans and 200,000 metric tons of soy oil to the Soviets during the next fire years. Brazil also agreed to sell a minimum of 2.5 million metric tons of corn starting in 1983. A metric ton is 2,204 pounds.

The Soviet Union agreed to export 20,000 barrels of oil daily for the next five months to Brazil at the price of $35 per barrel. The agreement is to be renegotiated before the end of the year. The amount represents 3 percent of Brazil's oil import requirements.

Brazilian sources said the Soviets had sought commitments for greater amounts of Brazilian grain. On their part, the Brazilians would like to buy more Soviet oil because supplies have been badly affected by the Persian Gulf war. Both Iraq and Iran were major Brazilian suppliers.

The Soviets also sought long-term commitments on other commodities. The agreement provides for annual shipments of 10,000 metric tons of Brazilian cocoa and 10,000 tons of cocoa liqueur in a five-year period.

Another protocol signed today called for the sale of Soviet turbines and other equipment for the Ilha Grande hydroelectric plant in Brazil, although the payment for the Soviet equipment is yet to be settled. Delfim Netto said he expected that these purchases could be paid with Brazilian manufactured goods. The value of the turbine deal is about $135 million.

The brazilian minister was accompanied here by 123 Brazilian businessmen and industrialists.

The two sides also reached agreements on technical cooperation in the energy field, a deal providing for Soviet technical assistance in drilling research and an accord calling for the establishment in Brazil of a plant using Soviet technology to produce alcohol from wood.