It hasn’t reached the Supreme Court for a decision, but lower courts have basically said that it’s not establing a religion because it’s used in a secular and patriotic fashion. (My interpretation of my understanding of the ruling).
The way it was worded basically said that it had to be the national motto, thereby not making it a religious text to bypass the concerns you mentioned.