Over 50 species of birds are known to habitually stand on one leg for long periods. The reasons why they do it are disputed :
Flamingos are thought to stand on one leg to reduce muscle fatigue or heat loss. The muscle fatigue hypothesis assumes that standing for long periods requires sufficiently high levels of active contractile force that would fatigue muscle, necessitating alternating stance from one leg to the other. Conversely, the heat loss hypothesis assumes that the energetic cost of activating muscles for the one-legged stance is smaller than any heat savings realized."
See: Mechanical evidence that flamingos can support their body on one leg with little active muscular force Biology Letters, May 2017, Volume 13, issue 5.
Also see: Why do birds stand on one leg? – A pilot study of exotic and native New Zealand birdsNotornis, 2010, Vol. 57: 173-177
And: Unipedal Postures in Birds , Biological Sciences Group, University of Connecticut.