This week's Torah portion, named "Bamidbar," which means "in the desert," is always read preceding the holiday of Shavuos, when we celebrate the giving of the Torah at Sinai, more than 3,300 years ago, in the year 1313 BCE. 
One reason for reading this portion as a preparation for Shavuos is because the Torah was given "bamidbar," in a desert. It was at Mt. Sinai in the Sinai desert where the newly liberated Hebrew slaves were molded into a nation and given the blueprint for repairing the world. But that only carries the question over: Of all places, why indeed was Torah given in a wilderness?
What is more, our sages describe Sinai as the marriage between G-d and His people; whoever heard of getting married in a barren desert? The Torah should have been given in a splendid environment, perhaps in the Hilton or the Waldorf-Astoria, not in a desolate wilderness!
Let us introduce one more question: Why was it necessary for the Jewish people to wander 40 years in this desert before entering the Promised Land? Was 210 years in Egypt, including more than 80 years of hard labor, not enough? Why liberate them from Egypt only to put them through another 40 years in the wilderness? 
There are many explanations for the unique relationship between Torah and the desert. Here are three.
1) Had the Torah been given in a civilized city or community, people might have defined it as a product of a particular culture, milieu, and environment. Sophisticated academics would explain to us the particular "genre" of Torah, as if it were an outdated, modern, or post-modern, piece of literature, an epic or lyric, a work of history, law, tragedy, or philosophy. They would enlighten us as to whether Torah belonged to the time of the Athenians, the Hellenistic age, the Greco-Roman period, the Byzantine age, or another period of civilization. Torah would be labeled, classified, and qualified. It would be "put into perspective."
But Torah cannot be put into a particular cultural or artistic perspective. Torah is not culture, literature, art, history, law, or fiction. Torah embodies the eternal truths about existence, life, and destiny that speak in every language, in every culture, in every age, and to every soul. The Torah cannot be reduced to a particular time frame or reference point. It benefits all the arts but never competes with them.
Professor Abraham Joshua Heschel (himself a scion of the great Chasidic masters) put it thus:  "Why does the Bible surpass everything created by man? Why is there no work worthy of comparison with it? Why is there no substitute for the Bible, no parallel to the history it has engendered? Why must all who seek the living G-d turn to its pages?
"Set the Bible beside any of the truly great books produced by the genius of man and see how they are diminished in stature. The Bible shows no concern with literary form, with verbal beauty, yet its absolute sublimity rings through all its pages. Its lines are so monumental and at the same time so simple that whoever tries to compete with them produces either a commentary or a caricature. It is a work we do not know how to assess. Other books you can estimate, you can measure, compare; the Bible you can only extol. Its insights surpass our standards. There is nothing greater. In three thousand years it has not aged a day. It is a book that cannot die. Oblivion shuns its pages."
"Absolute sublimity." Such a work must be taught and transmitted in a desert. A desert is not associated with any particular culture or form of living. A desert is barren, raw, and plain. A desert is not sophisticated; it is real and simple. 
2) Had the Torah been given in a particular city or community, its inhabitants would have claimed copyrights on it. Had the Torah been given in Boro Park, Crown Heights, Williamsburg, Lakewood, or Monsey, these communities would claim "ownership" of the Torah. "We know how to interpret Torah, how to assess it, how to appreciate it. It belongs to us." The same would hold true if the Torah was given in Teneck or the Upper West Side.
The desert, on the other hand, is ownerless. Nobody wants the desert. It belongs to nobody. Torah, too, is ownerless. It belongs to every Jewish soul on earth. Nobody holds any "rights" to the Torah. It is the living, vibrant conversation of G-d with every living Jew.  No group, denomination, or community "owns" it more than anyone else. (Of course, those privileged to study Torah and adhere to its integrity and formula ought to teach and inspire; but nobody owns it.)
Life in the Fast Lane
3) Had the Torah been given in a civilized and splendid terrain, we might have believed that its objective was to guide the beautiful life and the splendid heart.
But that is not Torah.
Torah does not tell us that life is easy and that faith is bliss. On the contrary, we were placed in a personal and global wilderness, and life is a battle. And it is precisely this battle that G-d intended us to face, day in and day out. Do not be disturbed or demoralized, the Torah teaches, by your traumas, challenges, inconsistencies, and weaknesses. Do not be shaken when you do not live up to your highest aspirations, and often do not actualize or maintain your inspiration. Do not be discouraged; because the Torah was given precisely to help us pave a road in the barren desert of the human psyche, to create a highway in the jungle of history and in the personal jungle of our anxiety-ridden brains.
Had the Torah been given in a beautiful city, then all we would have is a guide on how to live in beauty, in ecstasy. But Torah came to teach us how to confront our wilderness and to transform a desert into a paradise.
That is how the spiritual masters explained the reason for the Torah being given on a mountain. Why a mountain, and not flat land?
A mountain is essentially elevated earth. That is the profound message of Torah: With earth, gravel, dirt and mud, you must battle. That is intrinsic to the human condition and the reality of our world. Yet you must remember that your mission is to elevate the earth, to introduce holiness and G-dliness into a mundane and soiled world.
G-d did not desire holy people doing holy things; he wanted people who think they are unholy doing holy things; to disentangle themselves from the voices that tell them they are anything but whole and one, derivatives of infinite oneness.  He desired that earthly human beings become mountains of moral dignity and divine grace.
 Rambam Hilchos Tefilah 13:2. Tur and Schulchan Aruch Orach Chaim 428:4
 Mishnah Taanis 26b. Midrashim and commentaries on the Song of Songs. Cf. Rambam Hilchos Teshuvah chapter 10
 The Bible records that the wandering 40 years was a punishment for the sin of the spies who persuaded the people to reject their mission of entering the land of Israel. But certainly, G-d could have punished them in different ways. Why did He choose this particular consequence?
 G-d In Search Of Man pp. 240-242
 A similar idea is expressed in Midrash Rabah Bamidbar 19:26 and Midrash Tanchumah Chukas 21
 Yalkut Shemoni to Yesro Remez 275
 Sefer Hamaamarim 5655 p. 188
 See Tanya chapters 27; 36