And God said, Let there be lights in the firmament of the heaven to divide the day from the night; and let them be for signs, and for seasons, and for days, and years: - Genesis 1:14

At the end of the fourth day's work, the LORD said these things were good. According to a Hebrew tradition reported by the first-century Jewish historian Flavius Josephus, the science of astronomy was first invented by the virtuous children of Seth, the son of Adam, not heathen idolaters:
 
Now this Seth.... did he leave children behind him who imitated his virtues.... They also were the inventors of that peculiar sort of wisdom which is concerned with the heavenly bodies, and their order.
 
But in the way of our fallen world, the simple study of God's celestial creation eventually became contaminated with idolatry. The LORD through Moses commanded Israel to worship Him alone and not the creation:

And lest thou lift up thine eyes unto heaven, and when thou seest the Sun, and the Moon, and the stars, even all the host of heaven, shouldest be driven to worship them, and serve them, which the LORD thy God hath divided unto all nations under the whole heaven. - Deuteronomy 4:19

However, the astral worship of the time of Moses was not yet the same thing as "astrology" as we understand the term today. By about 700 B.C., the pagan Babylonians were finding omens in the sky - "bad signs" that were interpreted as predictions of trouble. These omens were probably found by observing an event in the sky such as an eclipse and attributing it as the cause of a terrible event on the Earth:
 
On the 20th day an eclipse happens. The king on his throne is slain, and a nobody on the throne seizes. - from the Babylonian "Table of Portents"
 
It's not hard to understand how the deception of astral worship would lead these pagans to seek the will of their false gods in the heavens. However, the LORD again instructed Israel to not get caught up in the deception of viewing celestial events as ominous:

Thus saith the LORD, Learn not the way of the heathen, and be not dismayed at the signs of heaven: for the heathen are dismayed at them. - Jeremiah 10:2

Modern devotees of astrology like to claim great antiquity for their superstition, that astrology in its current form goes back as far as 2000 B. C. or even earlier. Some Christian critics of astrology have suggested that it goes back to "Nimrod" and the Tower of Babel. However, there is no evidence for either belief, in the Bible or in any secular historical records. The fact is the familiar newspaper horoscope-type astrology did not exist until about 50 B.C.! What we typically think of as "ancient" astrology is actually a relatively recent product of the Roman empire, not ancient Babylon!
 
A system of associating celestial omens with events on the Earth began to be developed in Mesopotamia after 600 B.C., in the centuries "between the Testaments." This system was eventually adopted by the ancient Greeks following the conquest of Babylonia by Alexander the Great. The version of astrology commonly seen today is based on the failed, discredited pseudoscience of the ancient Greeks. 

Aristotle

In about 330 B.C., the Greek philosopher Aristotle created a fairly complete system of describing and understanding the natural world. However, Aristotle's system was essentially "armchair science" derived from logic alone. Aristotle would essentially make a casual observation of a natural phenomenon and then dream up a logical explanation that appeared to fit the facts of what was observed.
 
There was no process of experimentation in Aristotle's approach to confirm any of his logically-derived conclusions. Thus, Aristotle did not employ the modern scientific method of rigorously observing and measuring these natural phenomena to discover a mathematical pattern to the data. Aristotle's method was therefore "hit or miss." Sometimes he reasoned his way through to a correct explanation but very often he missed the boat completely. But since the logical form of his arguments was impeccable, his authority was unquestioned for centuries. Aristotle's philosophy was the standard for science for 2000 years, until the rise of modern scientific methodology in the 17th and 18th centuries. 
 
Much of Aristotle's science was based on the ancient Greek notion that all matter was made from four elements - earth, air, fire and water. It was believed that all substances in the real world are made up of portions of these elements. Take wood for example - it was observed to contain water and released fire when exposed to a fire, leaving behind an earthy ash. In our world of modern chemistry, this seems laughable, but it was serious science for a very long time.
 
Aristotle's science was based on the notion of "contrary qualities" - that each of the four elements have combinations of opposite properties of hot or cold and dry or moist. Thus, earth was held to be cold and dry. Water was considered cold and moist. Air was moist and hot and fire was dry and hot. Upon the advent of astrology, these same contrary qualities came to be associated with the Sun, Moon, planets and each of the constellations through which these celestial bodies were observed to pass.