A health insurance bill to cover catastrophic illnesses cleared a major legislative hurdle late Wednesday.

The compromise, providing the largest expansion of Medicare in the program's 23-year history, was agreed to by a House-Senate conference committee. It must win final approval from both chambers, but that is a foregone conclusion given the broad support that the basic measure received last year when it cleared the two houses in different versions.Health and Human Services Secretary Otis R. Bowen told conference committee members that he will recommend that President Reagan sign the legislation, even though it is considerably more ambitious than the measure proposed by the administration a year ago.

The basic framework of the legislation has been in place for months: providing protection for America's 31 million Medicare recipients against runaway hospital and prescription drug bills accumulated during acute illnesses. But House and Senate negotiators have worked since February to iron out the details.

The compromise legislation provides for Medicare coverage for hospital stays lasting up to 364 days; a first-day deductible still will be charged. Medicare now pays full hospital bills for only 59 days a year.

Regarding doctor bills, Medicare now pays no more than 80 percent of approved charges, no matter how high they run. Under the catastrophic health provision, Medicare will pay 100 percent of allowable fees after an individual has incurred $1,320 to $1,400 in out-of-pocket expenses.