Cardinals wear red ones. The Pope wears a white one. Rabbis often wear black ones. What's the difference?
Well, in this case, form does not follow function. Let's start with rabbis. Theirs are called kippot (pronounced keypoat), which is the Hebrew word for skullcap. The singular is kippah (keypah). You might have also heard them called yarmulkes (pronounced yamakas), which is a Yiddish word taken from the Polish word for skullcap. The reason why rabbis and many observant Jews wear them is because the religious book, the Talmud, orders them to: "Cover your head in order that the fear of heaven may be upon you."
So basically, it's a way of showing respect for God.
Cardinals and Popes, on the other hand, wear zucchettos, which is the Italian for a small gourd. (This may be because the panels sewn together to make the cap resemble the dome of a pumpkin or gourd.) The tradition of wearing the skullcap is markedly different from the rabbinic tradition. Catholic clergy originally wore them to address two issues: their short haircuts and the problem of not having a hood on their copes. Monasteries used to insist that men shaved the crown of the head, based on Paul's writing: "Does not nature itself teach you that if a man wears long hair, it is degrading to him"¦" (1 Corinthians 11:14) In fact, to this day, when the Orthodox talk about the day on which a priest was ordained or a monk entered a monastery, they refer to the date he was tonsured, which is the fancy word for buzzed.
Combine this, with the fact that copes with hoods went out of fashion in the 13th century, and you begin to see where the tradition comes from. Yes, they were cold in the winter! (What with the lack of modern-day heating and such in our cathedrals.) Of course, today they don't need them to stay warm, but the tradition lives on.
And there are other religions and other similar traditions of covering the head. Zoroastrians wear topis; Druze men sometimes don a doppa and Buddhists often wear a bao-tzu.