Most animals relax their muscles during sleep. With birds, it’s different.
The tighter the muscles in birds, the stronger and healthier their sleep. During sleep, the muscles are in such a state that the feathered birds cannot straighten their legs. The fingers tightly grasp a twig or a perch and turn into a strong lock, which will open only after waking up.
By the way, some birds sleep standing up. And even in the water. Flamingos and herons like to doze in this way. It is believed that they press up one leg to keep warmth and body temperature. Storks can sleep right during their flight (although they take turns doing it), and the dark tern sleeps in flight over the sea.