HAVANA (AP) _ Even after three decades as a master orator, Fidel Castro seems uneasy before a speech.

This night, about 50,000 students await him outside the presidential palace.

In the minutes before Castro steps to the podium, he can hardly keep still. He glances around and shifts his feet. He seems hardly to notice when the throng beneath him chants ''Fidel 3/8 Fidel 3/8''

It is an extraordinarily difficult period for him and his country. Not since the 1960s, when the Cold War raged and U.S. hostility seemed irrepressible, has Cuba faced such uncertainty.

How different things are from that day in 1974 when Castro predicted confidently, while host to President Leonid I. Brezhnev of the Soviet Union, that communism eventually would triumph in the world.

''Can anyone doubt it?'' he asked.

Those were heady days for the revolution. The United States seemed shaken to its roots by the Watergate scandal and skyrocketing oil prices. American troops had been forced from Vietnam a year earlier; the Communist conquest of Indochina was imminent.

But the world has turned upside down.

Communism appears to have failed in Indochina and has collapsed in Eastern Europe. There are predictions of cataclysmic internal upheaval in the Soviet Union, and Moscow's future economic support for Cuba is uncertain.

Against this unpromising background, the students convened outside Castro's headquarters one night this month to hear the leader speak.

The mood was upbeat. The students chanted slogans, with a recurring anti- American theme: ''Fidel, for sure, hit the Yankees hard.''

Someone shouted: ''Anyone who doesn't jump is a Yankee 3/8'' Everyone jumped. Castro smiled and jumped, too.

His message was simple: There is no reason to fear because ''the ideals of our country are immortal.''

''Not only will the revolution not fall, it will rise,'' he said.

Castro spoke for 90 minutes and was interrupted dozens of times by chants and applause.

His commitment to Communist fundamentalism is enshrined in the slogan he now uses at the end of every speech - ''Socialism or Death'' - and huge numbers of Cubans seem prepared to stick with him.

In that sense, Cuba is not comparable to the countries of Eastern Europe, where the leaders who fell last year were often hated by their people.

Arrayed against the pro-Castro militants are what appear to be growing ranks of disaffected Cubans.

Five years ago, the average number of Cubans fleeing by boat to Florida, 90 miles away, was one a month. According to U.S. figures, the monthly average has reached 40, despite the threat of prison terms ranging from one to three years. A resourceful teen-ager recently made the trip on a surfboard.

Jorge Luis Pichardo, a 26-year-old safety inspector who fled to Miami on a raft last August, said pay in Cuba allows people ''to subsist but not to live.''

A friend who accompanied him, Gustavo Brugues, son of Cuba's ambassador to Bolivia, said he once spent two days in a food line to buy pork for a family celebration. ''Sometimes, you have to wait in line and there's nothing at the end of it,'' he said.

On the other side are people like Juan Aizpura Rodriguez. He was a 15-year- old dropout at the time of the revolution in 1959, a poor, black youngster from one of Havana's many tough neighborhoods.

Aizpura now has a college degree in social science and is on the national board that governs neighborhood watchdog groups called Committees for the Defense of the Revolution. The groups provide social services and keep an eye out for anti-government activity.

''If it weren't for the revolution, the broadest majorities of our population ... would still be suffering,'' Aizpura said.

Perhaps the most pampered Cubans are the children. The amount spent on their health care and education is unusually high for a Third World country.

At a school for slow learners, one of 14 in the capital, the emphasis is on individual attention. It has 47 staff members, one for each 4 students. Buses take the students from home to school and back.

All education has a high priority in Cuba. The number of schools 30 years ago was a small fraction of those functioning today.

Nationwide vaccination has sharply reduced childhood diseases like measles and whooping cough. Polio was wiped out in 1963.

The official infant mortality rate is 11.1 per thousand, putting Cuba almost on a par with industrialized countries. Before the revolution, the rate was 60.

''We think we can still reduce it more,'' said Dr. Evilio Cabezas of the Public Health Ministry. He credited extensive prenatal and postnatal care, and added: ''It's all absolutely free.''

What kind of lives do these literate, healthy Cubans have? They are certainly better off than an estimated 175 million Latin Americans living in poverty, which Castro says is a byproduct of capitalism.

Cuba has hardly any beggars. Begging is illegal.

Unemployment is much lower than elsewhere in Latin America and drugs are far less of a problem than in the United States. Prostitution has been outlawed, but not eradicated.

A U.S. official who is an expert on Cuba said the revolution had improved life for one-third to one-half of Cuba's people.

Lack of freedom is a prime reason why Cubans leave home. The current political uncertainty has brought harsh repression of human rights activists and the number of detentions has increased sharply.

Twice in recent weeks, pro-government mobs have formed outside the homes of dissidents.

One of those homes belonged to Gustavo Arcos, who has spent a total of 12 years in prison since breaking with Castro in 1965. ''The rules of the game have changed,'' he said. ''They are not going to permit any more dissidents.''

Daily life can be demoralizing.

Food markets are dingy and poorly stocked. Apathy at work is common. Opportunities for recreation are limited.

Television often is dull. Comparatively few Cubans have their own cars and a trip across town on the erratic bus system can take hours.

Some medicines are unobtainable and decent housing is in acutely short supply. Some residential areas of Havana are in such disrepair they resemble war zones.

Can Castro survive? His political thinking is out of line with the democratic trend among Moscow's allies, but Castro points out adversaries have underestimated him before.

Much will depend on the attitude of the Soviet Union, which contributes $5 billion a year to subsidize Cuba's economy. Castro is preparing for the day when Cuba can no longer count on the Soviets.

He has acknowledged that a sharp reduction in Soviet oil shipments could force Cuba to replace tractors with mules, stop manufacturing adult clothing for five years and reduce bus service in Havana by two-thirds.

He expresses confidence the revolution will survive without the Soviets, but many experts claim severe hardship would cause an uprising.

Castro told the students: ''From each test, we come out more revolutionary. From each combat we come out better.''