The rabbis instituted a takanah to read a haftorah each Shabbos following the krias haTorah. The section read from the navi should always be related to the kriah (Tosfos Megillah 23a, s.v. "keivan").
Often the connection with the parsha is very obvious, but once in a while it is not that apparent. Sometimes there is both a superficial apparent connection as well as a more subtle one.
At first glance, the connection between parshas Bamidbar and the haftorah is obvious: the parsha deals with the census of the Jewish people taken in the midbar, and the haftorah opens with the prophetic statement that the population of the Jewish people will grow so much that it will be impossible to count them.
But there seems to be another, more subtle connection between the two. The halacha recognizes two stages in marriage: erusin and nissuin. When the chosson says "harei at" and gives the ring to the kallah she becomes an eishes ish, but only an arusa. Their marital relationship is not yet complete until the chosson brings the kallah into his home. This constitutes nissuin, and only at that point does the halacha declare that the couple is considered "one": ba'al k'ishto, and isha k'ba'alah (Sanhedrin 28b).
The relationship between Hashem and His Jewish people is described in Tanach as one of marriage. The prophets state that Hashem has never - and will never - "divorce" his "spouse". He always was - and always will continue to be - a most faithful spouse; even though perhaps we didn't really deserve such loyalty.
Nonetheless the Talmud points out (Yoma 54a) that our "marital relationship" with Hashem fluctuates between the stage of erusin and that of nissuin. When the aron (with the luchos) is in its proper place in the kodesh hakodoshim, the relationship is compared to the more intense state of nissuin. When there is no Beis Hamikdosh, or even during the period of the second temple when the aron with the luchos was not in its proper place, the relationship was compared to the incomplete state of erusin.
The Talmud relates that during the period of the first Temple, when the Jews would come to visit on the sholosh regalim, the kohanim would roll up the curtain in the paroches to show the "olei regalim" the cherubim hugging each other on top of the aron "as a husband would hug his wife" (Melachim I, 7:36). This demonstrated the great love that Hashem always has for His chosen people. But the concluding passuk in parshas Bamidbar indicates that when the mishkan was taken apart, it was forbidden for outsiders (other than the kohanim who were needed to pack up the aron) to look at the aron. The Talmud relates that during the period of the second temple one of the kohanim noticed that one of the tiles on the floor was not properly aligned with the others. He picked up the tile and realized that this was a secret trap door which led to the basement. When he entered the basement he saw "the lost ark" and stared at it for a while. This was not allowed, and for this he was punished.
When the relationship with Hashem is compared to one of nissuin, of course the couple may stare at each other. They are living together intimately. But during the period of erusin, we're not even permitted to stare at the aron.
In the haftorah the navi Hoshea prophecies that the day will come when the Jewish people will return to Eretz Yisroel and no longer will refer to Hashem as "ba'ali", but rather as "ishi". According to the interpretation of the Mishne Lamelech (last paragraph of his book "Poroshas Derachim", based on Pesachim 87a), this means that our relationship with Hashem will be restored to that of nissuin as opposed to the state of erusin we've been in since the aron with the luchos was removed from the kodesh hakodoshim in the days of Yoshiyahu Hamelech.
In a similar fashion even a superficial glance at parshas Beha'aloscha and its haftorah would lead one to notice the obvious connection between the kriah and its haftorah. The parsha opens with the mitzvah of kindling the menorah, and the navi Zecharya has the prophetic vision of the menorah of the second and third temples.
After some careful study, there seems to be a more subtle and fundamental connection between the two. Rambam (Peirush Hamishnayos on Sanhedrin, perek Cheilek) lists what he considers to be the thirteen principles of faith. Among them is that we believe that the level of Moshe Rabbeinu's prophecy is higher than that of all the other prophets. The source for this principle is the seventh aliyah in parshas Beha'aloscha. To use the language of the Talmud (Yevamos 49b), the prophecy of Moshe Rabbeinu was illuminated and crystal-clear, as opposed to that of the other prophets, whose nevuah was not that clear. To demonstrate this point, Rambam (Moreh Nevuchim, part II chapter 43) quotes from the nevuah of Zecharya, which happens to be the haftorah for parshas Beha'aloscha, that the navi had to ask the angel to explain to him what he had been shown. At first he simply could not understand what the prophecy was supposed to represent, until the angel explained it to him. This perhaps is a more significant connection between parshas Beha'aloscha and its haftorah, as the entire story of the prophecy of Zecharya demonstrates the principle of faith spelled out in the sedra.