"King Grisly-Beard" is an old German folk-tale, one of many collected by the Brothers Grimm. They travelled widely over the length and breadth of the various German kingdoms and states, gathering together dozens of old folk tales and legends for publication. Many of the stories were transmitted orally, and so were never written down until Jacob and Wilhelm Grimm arrived on the scene. Oral transmission of folktales was a necessity in an era when the vast majority of people couldn't read.
The precise time periods in which these stories were written are generally unknown. Although the fact that many of the Brothers Grimm's tales are set in medieval times does give us a possible hint as to when they were first composed. As regards "King Grisly-Beard," the setting appears somewhat vague. The story is set in "a land far away in the East," which could be just about anywhere. Having said that, as with many of the Grimms' fairytales there are references—to castles, kings, maypoles, etc—that appear to ground the tale in the medieval period.
The early 19th-century, when the Brothers Grimm first published their tales, was the heyday of the literary and artistic movement known as Romanticism. One notable feature of Romanticism was its veneration of the Middle Ages, which was look at nostalgically as a time of greater cultural and religious unity in Europe, and which provided numerous artists, poets, and novelists with much inspiration.