Trans World Airlines Inc. said yesterday it lost $87 million in the second quarter, blaming the result on fare wars, the dollar's declining value, lower transatlantic traffic and a flight attendants' strike earlier this year.

Also reporting earnings yesterday were Merrill Lynch & Co. Inc., parent of the world's largest securities brokerage, which said its net income grew 35 percent in the second quarter from a year earlier.

Among chemicals manufacturers, Monsanto Co. said its net income rose 19 percent in the second quarter from a year earlier. Allied-Signal Inc., a diversified manufacturer of chemicals, plastics and electrical products, said its net income rose 22 percent in the second quarter from a year earlier, partly because of strong performances from Signal businesses in the company's operating segments.

B. F. Goodrich Co. said that, despite a sharp drop in sales because of a restructuring of its tire division, it had a small second-quarter profit, compared with a large loss in the 1985 quarter. Trans World Airlines, the nation's fifth-largest airline, said its loss compared with a profit of $18.1 million (35 cents a share) for the comparable period last year. Revenue for the second quarter totaled $731.9 million, a 29 percent drop from $1.03 billion in the second quarter of 1985.

Despite its magnitude, the loss was less than many airline analysts had speculated. There was a widespread view that TWA's second-quarter loss would rival the $169 million loss of the first three months of this year. Merrill Lynch & Co. Inc., which is based in New York, had after-tax earnings of $91.1 million (86 cents a share) on revenue of $2.3 billion in the 13 weeks ended June 27, up from $67.6 million (69 cents) and revenue of $1.8 billion in the comparable 1985 period, company officials said yesterday.

Merrill Lynch benefited from growth in commissions on client orders for stocks and robust demand for mutual funds. Monsanto Co., based in St. Louis, reported after-tax earnings of $148 million ($1.90 a share) on sales of $1.87 billion in the three months ended June 30, up from $124 million ($1.60), and sales of $1.63 billion in the corresponding 1985 quarter. Allied-Signal Inc., which is based in Morris Township, N.J., said it had earnings of $186 million on sales of $2.9 billion in the three months ended June 30, up from $152 million and sales of $2.4 billion in the corresponding 1985 quarter.

Earnings per share dropped 39 percent, to 99 cents, from last year's second-quarter earnings per share of $1.61.

Six-month net income was $372 million, an increase of $86 million, or 30 percent, over the $286 million earned last year. First-half sales were $5.9 billion, up 20 percent over last year, the company reported. B. F. Goodrich Co., based in Akron, Ohio, said its earnings totaled $23.8 million ($1.02 a share) on sales of $759.1 million, compared with a loss of $352.5 million on sales of $824 million in the 1985 second quarter. Last year's results included a $365 million provision to cover corporate restructuring, the company said.

For the first half of the year, Goodrich reported earnings of $3.1 million (10 cents a share) on sales of $1.48 billion. That compared with a 1985 first-half loss of $350.2 million on sales of $1.59 billion.