It was perfectly legal until the Bill of Rights was ratified. And even then, it was legal by the states until Amendment XIV was ratified. Now no government agency can endorse or deny religion. The rest of it is fine, of course.
As Madison wrote, the fruits of established religion have been:
"During almost fifteen centuries has the legal establishment of Christianity been on trial. What have been its fruits? More or less in all places, pride and indolence in the Clergy, ignorance and servility in the laity, in both, superstition, bigotry and persecution."
James Madison, Memorial and Remonstrance against Religious Assessments, [ca. 20 June] 1785
Madison was entirely correct. Notice we see those same characteristics today, in religious groups that advocate establishment.
Entirely correct? How about when his very Remonstrance speaks boldly of the Creator, which he used to argue against that establishment of a particular religion. Thus Madison was in no way opposed to using the idea of God in making law--just not the idea of forcing people to conform to a particular religion.
As I pointed out, Americans quite properly banned the teaching of religion in public schools.
(hardly)
Morality generally is taught in terms of citizenship. The most effective and likely the most used:
The Six Pillars of Character® are the core ethical values of CHARACTER COUNTS! These values were identified by a nonpartisan, nonsectarian (secular) group of youth development experts in 1992 as “core ethical values that transcend cultural, religious and socioeconomic differences”.
Each of The Six Pillar of Character traits are used within our CHARACTER COUNTS! program to help instill a positive school climate and a culture of kindness, making schools a safe environment for students to learn.
TRUSTWORTHINESS
Be honest in communications and actions • Don’t deceive, cheat or steal • Be reliable — do what you say you’ll do • Have the courage to do the right thing • Build a good reputation • Be loyal — stand by your family, friends, and country • Keep your promises
RESPECT
Treat others with respect and follow the Golden Rule • Be tolerant and accepting of differences • Use good manners, not bad language • Be considerate of the feelings of others • Don’t threaten, hit or hurt anyone • Deal peacefully with anger, insults, and disagreements
RESPONSIBILITY
Do what you are supposed to do • Plan ahead • Be diligent • Persevere • Do your best • Use self-control • Be self-disciplined • Think before you act • Be accountable for your words, actions and attitudes • Set a good example for others • Choose a positive attitude • Make healthy choices
FAIRNESS
Play by the rules • Take turns and share • Be open-minded; listen to others • Don’t take advantage of others • Don’t blame others carelessly • Treat all people fairly
CARING
Be kind • Be compassionate and show you care • Show Empathy • Express gratitude • Forgive others and show mercy • Help people in need • Be charitable and altruistic
CITIZENSHIP
Do your share to make your home, school, community and greater world better • Cooperate • Get involved in community affairs • Stay informed; vote • Be a good neighbor • Obey laws and rules • Respect authority • Protect the environment • Volunteer
https://charactercounts.org/program-overview/six-pillars/
How effective? are you saying that we have more morality using such a list than we did when we used a list like this:
I am the Lord your God...
You shall have no other gods before me.
You shall not make for yourself a graven image, or any likeness of anything that is in heaven above, or that is in the earth beneath, or that is in the water under the earth; you shall not bow down to them or serve them; for I the Lord your God am a jealous God, visiting the iniquity of the fathers upon the children to the third and the fourth generation of those who hate me, but showing steadfast love to thousands of those who love me and keep my commandments.
You shall not take the name of the Lord your God in vain; for the Lord will not hold him guiltless who takes his name in vain.
Remember the sabbath day, to keep it holy. Six days you shall labor, and do all your work; but the seventh day is a sabbath to the Lord your God; in it you shall not do any work, you, or your son, or your daughter, your manservant, or your maidservant, or your cattle, or the sojourner who is within your gates; for in six days the Lord made heaven and earth, the sea, and all that is in them, and rested the seventh day; therefore the Lord blessed the sabbath day and hallowed it.
Honor your father and your mother, that your days may be long in the land which the Lord your God gives you.
You shall not kill.
You shall not commit adultery.
You shall not steal.
You shall not bear false witness against your neighbor.
You shall not covet your neighbor’s wife, or his manservant, or his maidservant, or his ox, or his ***, or anything that is your neighbor’s.
The problem, which has been made evident since the 10 commandments have been erased from the peoples' memory, is that your list has no authority. It is merely a list of suggestions. They might be nice suggestions to you and me, but they will no doubt make some people uncomfortable, and therefore, using today's logic, they, too will have to be erased from public view. For in reality, they are just a recapitulation of the idea of "love your neighbor as yourself, without the understanding that "God made both you and your neighbor and you owe Him your allegiance."
But it's very interesting that you use that list, since it has to first establish authority, which it does in several ways, like "Do what you are supposed to do." and "Have the courage to do the right thing" and "Obey laws and rules • Respect authority". Who is this authority we are supposed to obey and respect? And when do we know when that authority is corrupt and needs to be challenged? If that authority is the President of the United States, and the values of said president change every 4 to 8 years, then your morality is of no lasting value, because it doesn't last.
Only an everlasting, wise and powerful God can both give us laws that stand the test of time (as even evidenced by your list) and can effectively punish those who stray from those rules.