This phrase seems to haunt people who learn Spanish. For some reason it shows up in textbooks as a standard way to say good-bye in Spain or Latin America. It isn’t.
The phrase certainly exists, and has been around for a long time. It is not, however, how most people say good-bye. Instead there is the most obvious and common word: adios. In addition, there are all the obvious, and thanks to the Terminator movies, familiar ways, such as “hasta luego”, “hasta la vista”, or “chau” (also spelled ciao, after the original Italian, in some places).
But “vaya con Dios” also means good-bye, literally. The phrase is formed of “vaya”, which is the third-person singular present subjunctive of the verb “ir,” meaning “to go”; “con,” which means “with”; and “Dios,” which of course means God. The subjunctive verb here expresses a hope or desire, not just a possibility. Linguists refer to this as a hortative or jussive subjunctive. In other words, in idiomatic English, “God be with you” or “go with God”.
This is after all what “good-bye” really means. The standard phrase is a corruption, a fancy linguistics word which means something changed over time, of “God be with you,” which comes from “God be with thee,” where the “th” in thee was usually written with a “y” until about 400 years ago.
All of this comes from Latin, of course, which long before the Middle Ages had provided the phrase “dominus vobiscum” to say “God be with you” or “go with God”. The standard way to say good-bye in classical Latin was “vale” or “bene vale”, since at the time Romans believed in many gods and the rise of Christianity and the influence of the Catholic Church lay centuries in the future.
Nowadays, “vaya con Dios” is still used amongst older people, and also by priests as a way of giving a blessing, particularly after confession. Similar phrases, “que Dios los acompañe” meaning “may God be with you” and “ve con Dios” meaning “go with God”, are also used by elderly folks.
Otherwise, the phrase “vaya con Dios” and its companions are fading from the Spanish language. For an adult or child to use it would at this point be somewhat cute or awkward, and not at all appropriate. So use “adios” or one of the other more specific “hasta” phrases to say good-bye in Spanish. You’ll probably never need to say “vaya con Dios” unless you join the priesthood in Latin America.