This is actually a very complex issue and I'm not sure that people are really grasping how multifaceted this issue really is.
First of all, the notion that not everybody was prepared to receive certain teachings is something that predates Buddhist tantra by centuries. In fact, there was quite strict guidelines on who could be given teachngs on emptiness and there are lots of stories of how the arhats would faint, or vomit blood, when they heard these teachings. However, this idea is perhaps best exemplified by the Buddha's successive turnings of the Dharma Wheel, rather than a sense of secrecy as we find in the Vajrayana. This sense of secrecy seems to have historically first emerged due to the apparent afront to the vinaya that many of these practices seemed to entail. And considering that these teachings spread among the communities of the huge mega-monasteries of India, the need for secrecy was quite literally because these practices involved doing things that would get you kicked out of the monastery. In other words, these teachings promoted conduct that was, for a lack of a better word, illegal for monks to be engaged. However, this is just one aspect of why secrecy seemed to have developed in the Buddhist community. There is much more to this story, such as the highly competitive melee of the Indian religio-physical arena in which debates ended with the conversion of the loser, and their followers, to the winners view. Or the highly politically charged atmosphere in Tibet where the spread of certain teachings lead to banishment, or worse, and the translation of tantras was outlawed by royal edict. And, of course, there are much less worldly reasons for secrecy that have to due with the danger for students and especially teachers involved in the dissemination of teachings that are under the protection of powerful, and not always so pleasant, supramundane entities.
Anyway, I could go on and on about this, but I really just wanted to emphasize that this is a very intricate issue that spans a variety of very complex historical situations, as well the inner working of the relationships between, students, teachers, and the practices and teachings that gain them access to divine abodes that are not without their gate keepers.