In the days of monarchy the barons and earls pledged allegiance to the monarch. In those days oaths were considered binding for eternity -- even in the afterlife.
It was written by Francis Bellamy, and was published on September 8, 1892. It was a pledge to the republic for which the flag stands and not to any monarch. It had nothing whatever to do with any god. Representing a Union of independent States and still "indivisible." And with Liberty and Justice for ALL.
There were laws in place when I was in school describing the right way to display the flag. Then some SC Justice decided that burning the flag was "speech," not an action to be governed by law.