A couple armed with a gasoline bomb and other weapons held 150 students and adults hostage at an elementary school today but the woman was killed when the bomb exploded and the man then shot himself to death, the school principal said.

At least 74 people, most of them children, suffered second-degree burns when the bomb went off at about 4 P.M. at the Cokeville Elementary School. One teacher was shot when he tried to flee, the officials said. The authorities said the couple demanded $300 million in ransom.

The man gave the device to his wife to hold while he went to the bathroom, and she accidentally set off its hair-trigger mechanism, detonating it, said Sheriff Deb Wolfley of Lincoln County. Searchers Find Other Devices

''I thought we were all dead,'' said Christine Cook, a secretary who was in the classroom when the bomb went off. ''I heard this awful noise. It was smoke and flames. Just pandemonium.'' Two other explosive devices were found and removed, Mr. Wolfley said. The couple was identified as David Young and his wife, Doris. Residents said Mr. Young was the town's marshall for about six months six or seven years ago. They said he had been dismissed by the Mayor.

The police questioned two men and a woman about their involvement in the incident. The woman, believed to be Mr. Young's daughter, went to the authorities before the explosion, and the two men were found handcuffed to a white van that Mr. Young had driven into town earlier in the week. Principal Describes Scene

The school principal, Max Excell, said the couple entered the school about 1 P.M. and herded children, teachers and administrators into a large classroom.

Witnesses said the man distributed leaflets, demanded to talk to President Reagan and announced, ''This is the revolution.'' The pair asked $2 million ransom for each of the hostages.

Mr. Excell said the man said he had decided to press his demands at Cokeville, a town of about 550 people, because ''it was a rural community and people take care of their children. He had it very well thought out.'' He said the pair, who were in their 40's, ''behaved quite rationally most of the time'' although Mr. Young occassionally appeared confused. When Mr. Young was asked if he would release a 10-year-old child with diabetes, he said he wanted two 20-year-olds in the child's place, Mr. Excell said.

Mr. Excell said Mr. Young told him he expected the standoff to last 10 days because it would take that long for Congress to approve the ransom payment. Teachers Sang to Children

Pat Bennion, a substitute teacher at the school, told a reporter that teachers read and sang to the children and tried to keep them calm. She said the mother of one student, an applicant for a teaching position and a delivery woman for United Parcel Service were among the hostages.

The reporter said the teacher described the bomb as a crude mechanism consisting of a detonating device and two milk cartons filled with gasoline.

Mr. Wolfley said the bomb had a hair-trigger that had to be held down to keep it from exploding. When Mr. Young went to the bathroom, Mr. Wolfley said, he gave the bomb to his wife but her hand slipped and it went off.

Mr. Excell said Mr. Young then shot himself as the hostages looked on.

The children ''were all in the classroom when it went off,'' Mr. Excell said. ''The classroom was demolished. I don't know how they got out alive.'' Children Screaming Mr. Excell said John Miller, 30 years old, a music teacher, was shot in the shoulder as he tried to run down a hallway. Mr. Miller ran about 200 yards before collapsing, Mr. Excell said.

Children and adults with burns on their faces and arms streamed from the school after the explosion. They were ''completely hysterical,'' said Corrine Fredrickson, wife of the town's police chief. Many children lay on the ground screaming.

Donna Morfeld, a parent, said residents heard ''an explosion, two gunshots.''

Children were ''running in every direction,'' she said.

About a dozen ambulances and two school buses removed the injured.

There was ''a great deal of smoke pouring from the windows of the elementary school,'' said Ken Rand, news director for radio station KMER in Kemmerer. Threats to Children

At least 32 people with second-degree burns to their faces and arms were taken to Bear Lake Memorial Hospital in Montpelier, Idaho, about 30 miles from Cokeville, said Rod Jacobsen, the hospital's administrator.

Forty-two others were treated at hospitals in Kemmerer and Afton, officials said.

Mr. Miller was taken to Bannock Regional Medical Center in Pocatello, Idaho, for surgery, Mr. Jacobsen said.

Mary Lou Birch, the mother of one of the hostages, said the man was a former resident of the town and ''our city policeman.'' Mrs. Birch said the couple ''managed to get all the children and the faculty and staff members into one classroom, and then somehow or another notified the authorities that they had them.'' Bombs, Rifles and Ammunition

She said the couple threatened to start shooting if the ransom was not paid. ''When the bomb went off, he did start shooting,'' Mrs. Birch said.

The woman police were questioning tonight went to the town clerk's office shortly after the couple took the hostages, and ''said her father was going to blow up the school,'' said Nadine Dana, the clerk.

''There was a lot of ammunition, bombs, rifles, stuff like that,'' she said.

The Cheyenne office of the Federal Bureau of Alcohol, Tobacco and Firearms said it was sending agents to the school. Cokeville is in southwestern Wyoming, about five miles from the Idaho and Utah borders.