The shield of David is not mentioned in rabbinic literature. Notably, not a single archeological proof exists as yet concerning the use of this symbol in the Holy Land in ancient times, even after King David. A David's shield has recently been noted on a Jewish tombstone at Taranto, in Southern Italy, which may date as early as the third century of the common era. The earliest Jewish literary source which mentions it, the Eshkol ha-Kofer of the Karaite Judah Hadassi (middle of the 12th century), says, in ch. 242: "Seven names of angels precede the mezuzah: Michael, Gabriel, etc.... Tetragrammaton protect thee! And likewise the sign called 'David's shield' is placed beside the name of each angel." It was, therefore, at this time a sign on amulets.
In magic papyri of antiquity, pentagrams, together with stars and other signs, are frequently found on amulets bearing the Jewish names of God, and used to guard against fever and other diseases. Curiously enough, only the pentacle appears, not the hexagram. In the great magic papyrus at Paris and London there are twenty-two signs side by side, and a circle with twelve signs, but neither a pentacle nor a hexagram. The syncretism of Hellenistic, Jewish, and Coptic influences probably did not, therefore, originate the symbol. It is possible that it was the Kabbalah that derived the symbol from the Templars. Kabbalah makes use of this sign, arranging the Ten Sephiroth, or spheres, in it, and placing it on amulets.
A manuscript Tanakh dated 1307 and belonging to Rabbi Yosef bar Yehuda ben Marvas from Toledo, Spain, was decorated with a Shield of David.
In the synagogues, perhaps, it took the place of the mezuzah, and the name "shield of David" may have been given it in virtue of its presumed protective powers. The hexagram may have been employed originally also as an architectural ornament on synagogues, as it is, for example, on the cathedrals of Brandenburg and Stendal, and on the Marktkirche at Hanover. A pentacle in this form is found on the ancient synagogue at Tell Hum.
In 1354, King of Bohemia Charles IV prescribed for the Jews of Prague a red flag with both David's shield and Solomon's seal, while the red flag with which the Jews met King Matthias of Hungary in the 15th century showed two pentacles with two golden stars (Schwandtner, Scriptores Rerum Hungaricarum, ii. 148). The pentacle, therefore, may also have been used among the Jews. It occurs in a manuscript as early as the year 1073 (facsimile in M. Friedmann, Seder Eliyahu Rabbah ve-Seder Eliyahu Zt?a, Vienna, 1901).
In 1460, the Jews of Ofen (Budapest, Hungary) received King Mathios Kuruvenus with a red flag on which were two Shields of David and two stars. In the first Hebrew prayer book, printed in Prague in 1512, a large Shield of David appears on the cover. In the colophon is written: "Each man beneath his flag according to the house of their fathers... and he will merit to bestow a bountiful gift on anyone who grasps the Shield of David." In 1592, Mordechai Maizel was allowed to affix "a flag of King David, similar to that located on the Main Synagogue" to his synagogue in Prague. In 1648, the Jews of Prague were again allowed a flag, in acknowledgment of their part in defending the city against the Swedes. On a red background was a yellow Shield of David, in the centre of which was a Swedish star. 
Jewish lore links the symbol to the "Seal of Solomon", the magical signet ring used by King Solomon to control demons and spirits. Jewish lore also links the symbol to a magic shield owned by King David that protected him from enemies. Following Jewish emancipation after the French revolution, Jewish communities chose the Star of David to represent themselves, comparable to the cross used by most Christians. The star is found on the flag of Israel.
The shape of the star is an example of the hexagram, a symbol which has significance for other belief systems. The hexagram pre-dates its use by Jews. Its most prevalent usage outside of Judaism was and is the occult.
Modern Orthodox students proudly parade, in Manhattan NY, with Israeli flags which have a Star of David at the center
Some Orthodox Jewish groups reject the use of the hexagram because of its association with "magic" and the "occult". Yet the Star of David remains an important symbol within legitimate Jewish mysticism and the Kabbalah. Some Haredi groups, such as Neturei Karta, reject it because of its association with Zionism. Many Modern Orthodox synagogues, and many synagogues of other Jewish movements, have the Israeli flag with the Star of David prominently displayed at the front of the synagogues near the Ark containing the Torah scrolls. The Star of David can also be found on the tombstones of religious Jews going back hundreds of years in Europe as it became accepted as the universal symbol of the Jewish people.
A synagogue with the outline of a Star of David
Some researchers have theorized that the Star of David represents the astrological chart at the time of David's birth or anointing as king. The Star of David is also known as the "King's Star" in astrological circles, and was undoubtedly an important astrological symbol in Zoroastrianism.
Prof. Gershom Sholem theorizes that the "Star of David" originates in the writings of Aristotle, who used triangles in different positions to indicate the different basic elements. The superposed triangles thus represented combinations of those elements. From Aristotle's writings those symbols made their ways into early, pre-moslem, Arab literature. The Arabs were very interested in arithmetics, and were also very strongly drawn to occult and demonic tales. In fact, one of the most important personae in early Arab literature was King Salomon (Suliman). The Babylonian Talmud contains a legend about King Salomon being kidnapped by Ashmedai, the king of demons. He succeeded in kidnapping the king by stealing his "seal of Salomon" - (Arabic - Hattam Soliman), although according to the Talmud this seal was simply a metal coin with hebrew letters meaning the name of God, inscribed on it. It is possible that the seal was altered in the Arab tales. The first apparition of the symbol in Jewish scriptures was in oriental Kabbalistic writings, so it is possible that it was an alteration of the pentagram under Arab influence. Early Jewish sybols include the Shofar ("ram's horn"), Lulav ("shoot of palm"), and the seven-branch Menorah ("candelabra"), but no hexagram is found in early Jewish sybolism.