The pledge was written, by a minister in 1891 without the “under God” part. It was added by Congress in 1954 in the midst of Macarthyism and the Red Scare. In 2002 an appeals court said that forcing public school students to recite it was went against the separation of Church and State, and it was but stayed. The Supreme Court overturned that in 2004, but I think a lot of schools may have dropped it then.