to swear an oath: to make a solemn promise or statement binding by calling on God, or on something sacred, as its guarantor
To swear, in this sense, is not to curse or use bad language. It is a formal act: a person guarantees that they will do what they say, or that what they say is true, by invoking someone or something greater than themselves to hold them to it. The one who swears puts their own standing on the line before that guarantor.
In the New Testament the most weighty user of this word is God. Because there is no one greater to appeal to, God swears by himself (Hebrews 6:13), and the letter to the Hebrews returns to this again and again: God bound himself by oath to Abraham, to David, and to the priesthood of the Messiah, so that his promise would be doubly certain. A divine oath is not God adding truthfulness he lacked, but God stooping to human custom to make his commitment unmistakable.
Human oaths run alongside this. Herod swears rashly to a dancing girl and traps himself (Mark 6:23). The religious teachers of Jesus' day had built an elaborate system of what you could and could not swear by, and Jesus attacks it: swearing by the temple, the altar, or heaven all ultimately reach back to God, so the hair-splitting is dishonest (Matthew 23:16 to 22). Jesus and James press further, telling followers not to swear at all but to let a plain yes or no stand on its own (Matthew 5:34 to 36; James 5:12). Peter shows the darker side, backing up his denial of Jesus with oaths (Matthew 26:74; Mark 14:71).