I first heard it on the playground in the early '70s as:
“Beans, beans, bad for your heart.
The more you eat them the more you fart!”
Which made perfect sense to me because I and my sibs detested soybeans. Still not my favorite food but I’ll tolerate them in chili, which I didn’t get to try until I was a teenager.
And that was it, my peers didn’t know anything further, until later, when I’d been moved to a different state, an adult told the group of kids I was with the musical fruit/better you feel version, we instantly corrected that amongst ourselves to:
“Beans, beans, bad for your heart.
The more you eat them the more you fart
The more you fart, the worse you feel,
So don’t eat beans for any meal.”