It comes from the Old Testament practice of swearing oaths which were part of covenants.
Covenants form family bonds. Covenants ususally included a sacrifice and each party would swear to God that they would not break the covenant lest what happened to the animal should happen to them. The oath sealed the covenant, and each agreed that if they broke faith, they would wind up like the animal.
To involk the name of God and make an oath was to seal the covenant. You can swear an oath by Budda but Budda is not God and so you might as well swear by a tree or your car tire.
People think it is trite, something from a bygone era, but swearing on the name of God really isn't a trivial matter.
Now Peter was sitting outside in the courtyard. One of the maids came over to him and said, “You too were with Jesus the Galilean.” But he denied it in front of everyone, saying, “I do not know what you are talking about!” As he went out to the gate, another girl saw him and said to those who were there, “This man was with Jesus the Nazorean.” Again he denied it with an oath, “I do not know the man!” A little later the bystanders came over and said to Peter, “Surely you too are one of them; even your speech gives you away.” At that he began to curse and to swear, “I do not know the man.” And immediately a cock crowed. (Matthew 26:69-74)
God takes oaths seriously.
It's one of the reasons why we are forbidden to join organizations which ask members to swear an oath on matters of faith and morals. The legitimate authority on matters of faith and morals is the Church. it doesn't matter who the institution is, no institution may may assume the authority which God gave to the Church.