It's possible that the poem is a folklore piece that has been attributed to Franklin over time due to his reputation as a wise and learned individual.
If you find a specific source that attributes the poem to Franklin, it would be helpful to provide that information for further investigation.