The creation of golems is outlined in the Sefer Yetzirah, the Book of Creation. This book is generally grouped with Kabbalistic texts, and it describes the mystic way to create a golem. The mystics believed that God's spoken words were the origin of the creation of the world. These were not words as we know them, but instead were a system of pronunciation based on the letters of the Hebrew alphabet. The Hebrew letters have substance within the world, which can be harnassed to generate great power. This power requires deep meditation which is believed by Kabbalists to assist in cleaving to God, thus getting a broader look at His plans for creation. Stories of success by using specifically the method outlined in the Sefer Yetzirah don't seem to be as popularized.
However, there have been numerous legends of Rabbis creating golems throughout history. Often, rather than recitation of the words of creation, the golems are created by hand from clay, and words of power are inscribed on paper or upon the forehead of the statue. The words of power are always in Hebrew and are things like the word "truth" or the name of God. They would also have phrases like "God is truth." However God's exact name is in some dispute, and could be anywhere from the four letters (with vowels removed) YHVH to a string of 72 letters. Until the words of power are removed or altered, the golem is granted life.
Initially golems were created to prove a Rabbi's mastery of the Sefer Yetzirah. This was a way to cling or cleave to God and hopefully gain further insight into God's plan. Some Rabbis even created golems in the shape of goats, and used these golems for sacrifice to God. The eating of a golem animal, even though it would have split hooves, would not violate the Torah because the golem is not one of God's creations but that of Man's. However, golems were soon used for other more secular purposes. As golems are bound to serve their creator, they were made to perform simple tasks like drawing water from a well or protect villages from attack.
Golems are often considered to be extremely powerful, and in today's lore control of them can be easily lost. The uncontrollable and destructive golem is likely a product of anti-Semitic views combined with the burgeoning of the scientific outlook in the early Renaissance, when Jewish mystical texts began to be translated into Latin. Prior to this period, the golem seems to have no existance outside of the mystic texts describing its creation. The uncontrollable golems are loosely confined to those which were forced to perform menial tasks. These tasks would show an impurity in the purpose of the creator and would be against the set tenets for spiritual purity in golem creation. The longer the golem is used for such impure purposes, the larger it grows and the more unwieldy it becomes.
Recently golems have been used in fantasy stories to protect treasure, in tv shows to exact revenge upon murderers, and in horror novels as a child's worst nightmare. They have been attributed as inspiration for Frankenstein and other important works. The golem seems to be inherently evil by today's writers. It's likely this stems from religious teachings that man can not emulate God without suffering dire consequences. In addition to this, soulless creatures, like the golem, are often considered an abomination. The lack of a soul always seems to suggest a cripplingly low intelligence, with no moral standard to prevent any depraved acts. Something essential is missing, and such a creature can't "live" long without sinking below acceptable standards of society.