Are they just to light up the night? Does the bible even talk about other planets and other solar system with the capability of life or the people who wrote the bible does not know about these solar system because of lack of scientific advancement at that time?
The Bible does recognise the existence of heavenly bodies of some sort, and the fact that they move and come and go during the year:
However it calls them lights, which is how they appear from the earth. There is no reference to planets or other such worlds.
There was astronomy in late Biblical times: the Wise Men followed "a star" at the time of Jesus' birth. However the difference between astronomy and what we now call astrology was not clearly defined, and technology had not developed to the extent that Jupiter (the largest and most clearly-featured planet) could be seen to have coloured bands or moons. It was Galileo who first observed its moons, and he got into serious trouble for documenting it and supporting Copernicus.
We may say the Bible is incomplete in describing the heavenly bodies as lights rather than being more specific; but it was written by the writers of the time — they could not be expected to write down what they could not have understood.
They are just there to display the glory of God.
When we look at the sun, the moon, solar systems, galaxies, we see how great is our God and how big is our God. The universe declares the glory of God. The more we know about the universe, the more we are awed by the greatness of our God. Louie Giglio gave a sermon on the universe - "Indescribable (YouTube)", explaining that we can see the glory of God by simply looking at the universe. Here is one quote from the video (source) -
Here is an obscure answer that appears to have surfaced in the mid-1800s:
The purpose of the greater universe i.e. “stars etc.” is addressed in: Witness of the Stars, by E. W. Bullinger
Essentially, Bullinger along with others advanced that God in creation established the “Gospel” message in the stars. He goes into great detail within his book to show how the constellations depict the birth, death and resurrection of Jesus Christ. He believed that the stars proclaimed the same truth that we now have in the Bible. Therefore, mankind has never been without the Word.
He also used Psalms 19:1 as one of his proof verses:
Archeologists have discovered multiple mosaic floors in ancient Synagogues that depict the zodiac along side illustrations of Biblical stories. Most historians assume that this is evidence of the Israelites chasing after pagan gods. However, it could indicate that Bullinger was correct and these early depictions are remnants of divine understanding from an earlier time.
This answer is not without controversy, many have and still challenge the legitimacy of the message in the stars perspective. However, modern archeology and their discoveries of astrological signs within ancient synagogs and early churches may cause a resurgence of interest in this obscure perspective.
As to the purpose, Psalm 19 tells us that they, like all of creation, declare the glory of God: See also: God has created all things to bring glory to Himself.
As for the lack of scientific knowledge, and the ability of those that were inspired by God to write down His words, it's clear that they had knowledge that was unknown to science at the time.
On the matter of extra-terrestrial life and the possibility including planets capable of supporting life, the Bible is silent. I try not to speculate beyond that.
Please consider reading this regarding ancient times and planets - extra-biblical.
I know that I'm going to catch some flack for this comment, but it needs to be said to help answer this question. The bible is full of truths, but that doesn't mean that there aren't truths that exist outside of the bible. The Bible doesn't talk about the internet, subatomic particles, or how to calculate volume (Leibniz) or acceleration (Newton). That doesn't mean that they do not exist. It means it is out of scope for what the bible is - inspiration for daily living.
I believe it was Old Testament scholar Meredith Kline who suggested that the Tabernacle/Temple plan illustrated the whole of creation in microcosm, including the planets.
It starts with the court of the Gentiles and gets more exclusive the further you go in. In the main grounds, you have a picture of the earth with the laver representing the sea and the horned altar the horns or peaks of the mountains (the identification is easy to see in Hebrew, I am told, because the words are the same).
As you you enter the Holy Place, you go further up and further in, as it were, entering the heavens. There is the lampstand with the main pole plus three branches on either side, making seven lights in all. These represented the seven moving lights in the heavens (sun, moon, and the five planets visible to the naked eye -- Mercury through Saturn).
Beyond this is the Holy of Holies, which is the dwelling place of God.
Thus, the temple is a picture of the whole creation under God.
As for the purpose of the planets and the whole of the universe for that matter, others have noted well that the purpose of all creation is to declare the glory, power, majesty of God -- without words. Note that the locus classicus for this view is Psalm 19, which is divided into two halves: God's glory declared without words and God's glory in his perfect word.
I leaned on Gordon Hugenberger's sermons on Psalm 19 for this answer.