How did the Greybeards learn shouts?

Solution 1:

A full explanation can be found on the Thu'um wikia page:

In the early ages of Nirn the only beings capable of using the Thu'um were the dragons, the children of Akatosh. The Thu'um was part of their natural language and could be utilized as a weapon. They abused this power to bring havoc upon the races of man during the late merethic era. Among the leader of the dragons was Alduin, the World-Eater, who took to his belief that he was a deity and claimed his father Akatosh's place. Humans who worshiped the dragons were part of the Dragon Cult.

Kyne had pitied man and tasked Paarthurnax, Alduin's younger brother and second-in-command, to betray the Dragons and teach man the way of the voice. The humans then used the voice to fight the dragons, and had created their own shout, Dragonrend. They then used this shout, along with an Elder Scroll, to send Alduin through time and end the age of the dragons.

Thus, the origin of the Thu'um was when Paarthurnax betrayed the rest of the dragons and taught the humans how to speak their language. After the rebellion, humans, too, began to abuse the power this led to the creation of the Greybeards:

In time man too had abused the voice. Instead of using it as a form of prayer or use of self-defense, they instead used it as a mere weapon. Jurgen Windcaller founded the Greybeards on the Throat of the World and taught man to instead use the Thu'um as a force of peace and enlightenment, a teaching which now remains in the Greybeard code. Many greybeards have such a powerful Thu'um they could cause major destruction with a simple sentence.

Essentially, Paarthurnax taught the humans how to use the Thu'um in order to defend themselves. After the Thu'um became abused by humans, the knowledge of how to use it was only passed down through the Greybeards and only as a method of prayer or self-defense. This is why only the Greybeards know how to do it.