The Senate opened debate yesterday on a new code of ethics, with Democratic leaders predicting that a proposed $8,625 limit on outside earned income will survive attack and be retained in the code.

Majority Leader Robert C. Byrd (D-W.Va.) and Democratic Assistant Leader Alan Cranston (D-Calif.) said they believe attempts by Sen. Edmund S. Muskie (D-Maine) and three others to kill the limitation or to alter its present form will lose, despite reports that about two-thirds of the Senate's Republicans oppose the limit.

Senate minority Leader Howard H. Baker (R-Tenn.) said he will vote for the limitation.

Muskie, in a letter to senators, said the limitation is unfair because it doesn't treat all types of income alike. Earned income, obtained through speaking fees, would be held down, he said, thus harming senators who don't have large private fortunes. But the new code doesn't impose any restrictions on "unearned" income from interest, dividends and similar investments.

Muskie backers say some senators get tens of thousands of dollars of income from such sources.

Byrd, who is putting his personal prestige on the line to an unprecedented extent to get the code through in the form written by Sen. Gaylord Nelson (D-Wis.) and a special ethics unit, said retention of the ceiling and adoption of the rest of the code is absolutely necessary to assure the public that senators are honest men and to dispel suspicion of Congress.

"It is not out duty to direct ourselves to equalization of the income of senators," he said. Unearned income, such as dividends, is received passively and requires no special effort or work, but "earned income" requires "personal service to produce it . . . The potential for conflict of interest is much greater where a senator must perform personal services for the income." He said the strongest attacks on Congress derive from news reports about honoraria.

With a salary of $57,500 - just raised from $44,600 - plus the right to earn $8,625 more for speaking engagements, Byrd, said, a senator would have a total income of $66,125, putting him "in the top 1 per cent among Americans in earnings." He said the practice of senators leaving Washington to make speeches obstructs business, and rejection of the limit would be like saying "even $66,125 is not enough, we want more."

They'd just gotten a raise; they should accept an income limit, he said.

Bob Packwood (R-Ore.), a Muskie cosponsor, said he thinks the vote on the limitation can go either way in next week's vote.

Figures compiled by The Washington Post show that the four senators sponsoring the amendment to kill the $8,625 limit on honoraria and other outside earned income all have earned substantial amounts from such speeches in recent years.

Muskie, for example, earned $13,800 in 1975, $28,880 in 1974 and $34,977 in 1973. Packwood earned $24,000 in 1976, and between $14,300 and $17,050 from 1973 to 1975.

Bob Dole (R-Kan.), another Muskie cosponsor, earned $13,795 in 1975, $20,850 in 1974, $38,150 in 1973 and $33,050 in 1972. Birch Bayh (D-Ind.) the fourth cosponsor, earned over $14,000 in 1975 from honoraria and between $15,000 and $26,500 each year from $1972 to 1974.

Another senator who attacked the new code yesterday, Barry M. Goldwater (R-Ariz.), earned $44,733 in honoraria in 1973, and $25,190 in 1974, but only $4,117 in 1975. In 1976, however, he received $25,000 from a broadcasting network (as did George McGovern (D-S.D.) for acting as a commentator on the two political conventions.

The code, similar (though not identical) to one adopted by the House, applied to senators and senate employees making over $25,000, and requires public financial disclosures of all earned income and honoraria and reports on unearned income and assets and liabilities, though in less detail.

Earned income could not exceed 15 per cent of salary ($8,625 for a senator). It would be forbidden to engage in any professional occupation such as a law practice, a real estate or insurance business, medicine, architecture or the like. Members and employees also would be forbidden to serve as officers or board members of profit-making corporations or business.

Unofficial office accounts ("slush funds"), junkets after a senator has been defeated or announced retirement and the pocketing of leftover campaign funds also would be forbidden.

Winding up his speech, Byrd said senators are kidding themselves if they think they aren't taking advantage of their Senate fame in earning honorariums. "I don't think any group of citizens would pay me $2,000 to play my fiddle for 15 minutes if I were a meatcutter or working, in a shipyard or practicing law."