בָרוּךְ..... הַנוֹתֵן לַשֶכְוִי בִינָה לְהַבְחִין בֵין יוֹם וּבֵין לָיְלָה
"Blessed are you, HaShem... Who gives the rooster the understanding to distinguish between day and night."
Birkot haShaḥar is a series of blessings that we say in the morning thanking God for the renewal of the day. As we explained last week, as soon as we wake up we begin by thanking God for being alive (see this). Then, we pronounce the second blessing, acknowledging that the Creator granted the rooster the understanding to distinguish between day and night.
To properly grasp the rational of Birkot haShaḥar we need to bear in mind that these blessings were said as a person was waking up, getting up from bed, walking and getting dressed.
This blessing was pronounced when one would hear the rooster's crow. The rooster does not crow necessarily when it sees light or when the sun rises, but before dawn. Thanks to a biological process known as circadian rhythm, roosters can keep track of time after midnight, which is when they usually start crowing. Some species of rooster would crow four times during the night with the third cockcrow at around four o'clock in the morning (see a very interest article here).
This berakha emphasizes the fact that the Creator endowed the rooster with this extraordinary skill, which used to help us to wake up and serve our Creator (Time measurement is traditionally regarded as an exclusive human ability. Many Rabbis actually understood the word sekhvi not as rooster, but as "heart" or human cognition).
The Rabbis discussed if this blessing should be said only when we actually hear the rooster's crow (Maimonides) or even if we did not experience the rooster's crow directly (haAri). Yemenites and a few other Jewish communities follow Maimonides, but the majority follows the custom to recite this blessing anyways.