It is a didactic poem. A didactic poem always delivers a moral teaching or lesson for the mankind. This poem also has one, though not directly but through a legendary tale.
By its form, it is a ballad. A ballad is “a poem or song narrating a story in short stanzas.” Traditional ballads are typically of unknown authorship, having been passed on orally from one generation to the next.