Francis Bellamy originally published the Pledge of Allegiance in The Youth's Companion as an effort to bring citizens of the country closer. It read: I pledge allegiance to my Flag and the Republic for which it stands, one nation, indivisible, with liberty and justice for all.
The words "The Flag of the United States of America" was added to the pledge.
The Gobitis family took to court when their son got expelled for not standing and saluting the pledge for religious reasons. The supreme court ruled that a minor can be expelled for not standing and saluting during the pledge.
Marie and Gathie Barnett were instructed by their father to not salute to the American Flag, which got them expelled. They sued, and the court overruled the decision of Minersville v. Gobits in saying that forcing someone to salute to the pledge was a breach of the first amendment.
President Eisenhower pushed congress to add these words in response to the growing communist threats of the time.
Newdow brought a case to court saying her daughter shouldn't be forced to say the words "Under God" in the Pledge of Allegiance. The lower court decided that it was unconstitutional to force someone to say this. The Ninth Circuit Court of Appeals decided that it was constitutional how it was. The Supreme Court decided that Mrs. Newdow didn't have custody over her daughter and they couldn't hear her case.