Where does it say in the Torah to wear a Kippa?
Kippot\Yarmulkas are not explicitly mentioned anywhere in Tanach, although it is possible that covering one's head was a common cultural practice.
The first Halachic mention of covering one's head is in the Talmud, in the following places:
- Kiddushin 31a: R' Huna didn't go four amot with his head uncovered, saying "The Shechina is always above me."
- Shabbat 156b: R' Nachman's mother told him to always cover his head so that he would always have Yirat Shamayim (Fear of Heaven).
In other words, this is a minhag that started as a personal practice of some Amoraim to increase their Fear of Heaven. This custom soon spread to other distinguished Talmidei Chachamim (see Kiddushin 8a), and the masses slowly adopted it as well. By the 16th century, it was a widely accepted minhag,1 and there was strong rabbinic opposition to walking around bareheaded.
This minhag was codified as Halacha in the Shulchan Aruch (OC 2:6) - "One should not walk four amot with an uncovered head." For more details, see the Mishna Brura and Be'er Haitev on this siman. See also the Be'er Haitev on 91:3.
In addition: The Rambam (Hilchot De'ot 5:6) mentions an additional reason of "modesty."
Once it had been nearly universally accepted, a new reason developed, as mentioned in the name of the Taz (above): To differentiate between Jews and Gentiles \ So as to not imitate the Gentiles. (This is possibly based on Lev 18:3.) (See also Igrot Moshe או"ח I.1, the אוצר טעמי מנהגים/"Rite and Reason," and MaharShal Responsa 72.)
It says in the beggining of the Alter Rebbe's Shulchan Aruch (Shulchan Aruch Harav) that once it is the custom of people to cover that portion of their head, uncovering it is a problem with Tznius (like he mentions also walking without socks) which is more serious than a minhag.
The torah doesn't say that you should. It has become minhag yisroel to do it so that we fear hashem.
The Taz (OH 8:2) notes that there is a Torah-level issur of going bareheaded, under the category of ובחוקותיהם לא תלכו -- going in the ways of the other nations (Vayikra 18:3). (Whether the Taz's reasoning applies in our times when non-Jews aren't as careful about uncovering their heads out of respect is a separate question.) But that is a source in the Torah for the requirement to cover the head.