Edgar B. Speer, plagued by poor health for several years, stepped down today as chairman of U.S. Steel Corp., a post he had held for six years.

The announcement came as the nation's two biggest steelmakers-U.S. Steel and Bethlehem Steel Corp-announced sharp first-quarter earnings gains.

U.S. Steel, which lost $58.7 million in the first three months of 1978, earned $4i million in the first quarter of 1979. Bethlehem, which earned a meager $1.1 million in the first quarter of 1978, had profits of 58.7 million this year.

Speer, 62, will be succeeded by David M. Roderick, who has been president of the nation's biggest steel-maker since 1975. William Roesch, executive vice president for steel and domestic raw materials, was named president. U.S. Steel's board, which met here, said it accepted Speer's resignation "reluctantly."

Speer has been in poor health for more than two years, and last fall had a large portion of his stomach removed because of ulcers, according to company spokesmen.

Since then, he has been in his office infrequently, and Roderick, 54, has been handling both his job and Speer's, company sources said.

Speer's resignation was not unexpected. He announced last week that he would not stand for re-election to the board of American Telephone and Telegraph Co. because of poor health.

Assocaited Press reported the following:

Both corporations predicted increased profits for the second quarter of 1979.

"In each quarter since the first quarter of 1978, U.S. Steel's income has increased over the income reported for the comparable year-earlier period. This trend should continue in the second quarter," U.S. Steel said in a press release.

"Belthlehem Steel ahd a reasonably good first quarter," said Chairman Lewis Foy. "Barring unforeseen occurrences, the second quarter should be better."

However, both corporations also stressed that their returns on equity remain far below the average attained by all manufacturing industries.

"Increased profitability is essential in order to generate the necessary funds to expand and modernize facilities and to meet environmental requirements," U.S. Steel said.

Bethlehem said its net income was an unsatisfactory 3.4 percent of net sales for the period. This is slightly less than the 3.6 percent realized for 1978 and significantly less than the historical average for all manufacturing companies, Bethlehem said.

Both corporations said orders have increased. U.S. Steel said orders were at the highest quarterly level since the last portion of 1973.

"The improvement in orders is generally broad-based, and orders for products serving the capital goods markets have climbed steadily," U.S. Steel said.