Aniconism (prohibition of images) came to Islam by way of Judaism and its own prohibition of graven images. Exactly why Israelite religion adopted aniconism is still a debated question, but it probably predates Judaism, as evidence has been found that it was practiced elsewhere in the Ancient Near East before Jewish monotheism, most notably by the Phoenecians.
There is no consensus theory as to how or why Near Eastern aniconism originally developed. One theory is that it was a de facto nomadic practice which came as a result of a scarcity of resources in the desert for building idols which in turn led to the use of simple standing stones or poles as stand-ins for idols.
Brian R. Doak: Phoenician Aniconism in Its Mediterranean and Ancient Near Eastern Contexts
Tryggve Mettinger: The absence of images : the problem of the aniconic cult at Gades and its religio-historical background.
No Graven Image?: Israelite Aniconism in Its Ancient Near Eastern Context
Mark S. Smith: The Early History of God: Yahweh and the Other Deities in Ancient Israel
Ron S. Hendel: Aniconism and Anthropomorphism in Ancient Israel