There were most likely several safety precautions involved, especially with the merpeople themselves.
Dumbledore, and the other teachers, likely had several safety precautions in places to prevent harm to any of the students, as we see Harry realising.
Harry’s feeling of stupidity was growing. Now he was out of the water, it seemed perfectly clear that Dumbledore’s safety precautions wouldn’t have permitted the death of a hostage just because their champion hadn’t turned up. Why hadn’t he just grabbed Ron and gone? He would have been first back.
Harry Potter and the Goblet of Fire, Chapter 26, "The Second Task"
Ron also comes to pretty much the same conclusion before when Harry breaks through the water's surface with him and Gabrielle.
The crowd in the stands was making a great deal of noise; shouting and screaming, they all seemed to be on their feet; Harry had the impression they thought that Ron and the little girl might be dead, but they were wrong... both of them had opened their eyes; the girl looked scared and confused, but Ron merely expelled a great spout of water, blinked in the bright light, turned to Harry, and said, “Wet, this, isn’t it?” Then he spotted Fleur’s sister. “What did you bring her for?”
“Fleur didn’t turn up, I couldn’t leave her,” Harry panted.
“Harry, you prat,” said Ron, “you didn’t take that song thing seriously, did you? Dumbledore wouldn’t have let any of us drown!”
“The song said —”
“It was only to make sure you got back inside the time limit!” said Ron. “I hope you didn’t waste time down there acting the hero!”
Harry Potter and the Goblet of Fire, Chapter 26, "The Second Task"
In fact Dumbledore speaks Mermish and was in conversation with the chief merperson after all the champions had reached the surface. It seems likely that they would have had some measures in place with the merpeople in case anything bad should happen.
Dumbledore was crouching at the water’s edge, deep in conversation with what seemed to be the chief merperson, a particularly wild and ferocious-looking female. He was making the same sort of screechy noises that the merpeople made when they were above water; clearly, Dumbledore could speak Mermish. Finally he straightened up, turned to his fellow judges, and said, “A conference before we give the marks, I think.”
Harry Potter and the Goblet of Fire, Chapter 26, "The Second Task"
In fact this seems all the more the case when we see them watching Harry as he rises to the surface and is struggling.
Merpeople were rising with him. He could see them swirling around him with ease, watching him struggle through the water. ... Would they pull him back down to the depths when the time was up? Did they perhaps eat humans? Harry’s legs were seizing up with the effort to keep swimming; his shoulders were aching horribly with the effort of dragging Ron and the girl. ...
Harry Potter and the Goblet of Fire, Chapter 26, "The Second Task"
The merpeople were also heavily involved in the task and seem to know the rules of it, considering they wouldn't let Harry take more than one person.
Harry looked around. There was no sign of any of the other champions. What were they playing at? Why didn’t they hurry up? He turned back to Hermione, raised the jagged rock, and began to hack at her bindings too —
At once, several pairs of strong gray hands seized him. Half a dozen mermen were pulling him away from Hermione, shaking their green-haired heads, and laughing.
“You take your own hostage,” one of them said to him. “Leave the others...”
“No way!” said Harry furiously — but only two large bubbles came out.
“Your task is to retrieve your own friend... leave the others...”
Harry Potter and the Goblet of Fire, Chapter 26, "The Second Task"