Is it some sort of made-up substitute for transforming witch energy like Kyuubey did by eating the grief seeds, but with Bebe Witch instead
Remember that the world we see at the beginning is a false world and we later learn that it's
Homura's Witch Labyrinth contained in an Incubator Isolation Field
as such, we can probably assume that any and all reason for Magical Girls to exist (to balance entropy for the Incubators) won't apply here, and the Nightmares are just a way to explain (to the girls at least) why they are Magical Girls: probably as a means to stabilize the realism.
Since we see Homura's Familiars acting as some of the populace and when Homura begins to realize the truth as she is taken further away from her Soul Gem the Labyrinth's reality begins to become unstable like with the airships plummeting.
The Wikia seems to call the song a nursery rhyme game which would play into the playful nature of the Nightmares. As for the purpose, we see see with Hitomi's Nightmare it seems to be used to turn the Nightmares into something Bebe would eat to then revert the Nightmare back to their original form (as after the Girl's Soul Gems are purified, Hitomi reappears in her bed). Bebe being able to revert them must extend from the powers Madoka gave her when, along with Sayaka, the 3 of them first entered the fake world.