In the verses that precede Matthew 5:37, Jesus said that you’re not to swear by heaven or earth, and James 5:12 echoes that as well. The Pharisees were trying to play an end-run game and not use the name of God. Leviticus, Deuteronomy, and other passages say that if you swear by God’s name and fail to do what you are swearing, then there would be condemnation upon you. To swear by heaven or earth is a spiritual-sounding way to get around using God’s name such that it gives you an escape clause to not carry out what you are pledging to do. Jesus said to let your “Yes” be “Yes” and your “No” be “No” so that there would be an integrity about your word and the commitments you make.
There can be exceptions to the rule. For example, if you were to say to your child, “I am going to take you to play golf tomorrow,” and it snows the next day, then the changes in circumstances make it reasonable that you would not play golf in subfreezing weather in a snowstorm. Circumstances changing can have a certain effect, but by and large, you should be a person of integrity.
Psalm 15 and Psalm 24 both pose the question, “Who may come to the Lord’s holy hill, and who may come into fellowship with God?” Interestingly enough, there are only five or six distinguishing marks of the one who is welcomed into God’s presence to have fellowship with Him. One of those distinguishing marks is that you do not swear with deceit. You do not present something to someone falsifying your commitment so that you have an escape.
There are many verses that need to be brought to bear upon answering the question, but the idea is that you would not change your word for personal gain, that you would be willing even to suffer if the commitment you made is now going to cost you more than you realized.