Short answer
The Song of Solomon is in the Bible because Jews, and later Christians, read it as a picture of God's (﷾) love. The poem itself never says so, and never says it comes from God (﷾). It is a love poem between a man and a woman. It names God at most once, in one word that translators read differently. Its first line links it to Solomon, but the NIV Study Bible calls his authorship an open question. So it is in the Bible because of how people read it, not because of anything it says about itself. The Qur'an speaks of marriage too, with warmth, and all of it is given as guidance from God (﷾).
Full explanation
What the poem says
The Song is a set of love poems. A man and a woman praise each other's bodies and long to be together. There is no law in it, no prophet, and no call to worship God (﷾). The New Testament never quotes it.
“Thy navel is like a round goblet, which wanteth not liquor: thy belly is like an heap of wheat set about with lilies.”
“I said, I will go up to the palm tree, I will take hold of the boughs thereof: now also thy breasts shall be as clusters of the vine, and the smell of thy nose like apples;”
“O that thou wert as my brother, that sucked the breasts of my mother! when I should find thee without, I would kiss thee; yea, I should not be despised.”
God (﷾) is named at most once
Most English readers will not find God's (﷾) name in the Song at all. In 8:6 the King James Version reads "a most vehement flame". The World English Bible, a modern translation, reads the same Hebrew word as "a very flame of Yahweh". So even the one possible mention depends on how a translator reads a single word.
“Set me as a seal upon thine heart, as a seal upon thine arm: for love is strong as death; jealousy is cruel as the grave: the coals thereof are coals of fire, which hath a most vehement flame.”
“Set me as a seal on your heart, as a seal on your arm; for love is strong as death. Jealousy is as cruel as Sheol. Its flashes are flashes of fire, a very flame of Yahweh.”
Did Solomon write it?
The heading links the Song to Solomon, the king of Israel in the Bible, and he is named several times. But in 8:12 someone speaks to Solomon as another person. An evangelical study Bible, edited by an NIV translator, calls Solomon's authorship an open question.
“The song of songs, which is Solomon’s.”
“My vineyard, which is mine, is before me: thou, O Solomon, must have a thousand, and those that keep the fruit thereof two hundred.”
This evangelical study Bible notes that the first verse appears to ascribe the Song to Solomon, that Solomon is named seven times and several verses speak of "the king", but that whether Solomon wrote it remains an open question.
How it stayed in scripture
The Mishnah, the early collection of Jewish law, records rabbis disputing whether the Song counted as holy scripture. Rabbi Akiva, a Jewish teacher of the early second century, defended it in the strongest terms. The Mishnah rules that it is scripture.
The Mishnah records that the rabbis disagreed over whether the Song of Songs and Ecclesiastes "render the hands unclean", their way of saying a book is holy scripture. Rabbi Judah and Rabbi Yose each say one of the two books was disputed. Rabbi Akiva answers that no one in Israel ever disputed the Song, for all the Writings are holy but the Song of Songs is the holy of holies. The Mishnah's own ruling is that the Song, like Ecclesiastes, renders the hands unclean.
The Christian reading
Christians have long read the Song as a picture of the love between Christ and the church, or between God (﷾) and the soul. Origen, a Christian teacher of the third century, wrote the most influential early commentary in this way. The original King James Version headed its chapters to match.
The most influential early Christian commentary on the Song reads it as a marriage song in which the bride is the church, or the soul, and the bridegroom is Christ, the Word of God.
The original King James Version printed a summary over each chapter of the Song that reads the poem as about Christ and the church. Chapter 1, for example, is headed with the church's love for Christ.
Marriage in the Qur'an
The Qur'an honours married love. It calls husband and wife garments for each other. It names the love and mercy between them a sign of God (﷾). Every verse of it is given as guidance from God (﷾).
“They are your garments and ye are their garments.”
“And among His Signs is this, that He created for you mates from among yourselves, that ye may dwell in tranquillity with them, and He has put love and mercy between your (hearts): verily in that are Signs for those who reflect.”
“This is the Book; in it is guidance sure, without doubt, to those who fear Allah;”
What Christians say about the Song
Origen, Commentary on the Song of Songs (c. 240 CE)
The most influential early Christian commentary on the Song reads it as a marriage song in which the bride is the church, or the soul, and the bridegroom is Christ, the Word of God.
Cited for
The Song is an allegory of Christ and the church, so its imagery points to spiritual love.
The response
The poem never mentions Christ, the church or the soul, and the New Testament never quotes it. Readers brought the allegory to the Song. The rabbis first read it as God (﷾) and Israel. Later Christians read it as Christ and the church.
Where it lands — The allegory comes from the readers, not from anything the Song claims for itself.
Perspectives
Christian
The Song is inspired scripture. It celebrates the goodness of married love as God made it. Many Christians also read it as a picture of Christ's love for the church.
The early church read the Song as the love of Christ for the church and for the soul.
Rebuttal
That is true of Origen and many after him. But the poem never mentions Christ, the church or the soul, and the New Testament never quotes it. The allegory (a hidden second meaning) came from its readers, not from the Song.
The Song's heading ascribes it to Solomon.
Rebuttal
The heading does link the Song to Solomon. But even the heading does not say it comes from God (﷾). Inside the poem someone speaks to Solomon as another person (8:12), and an evangelical study Bible calls his authorship an open question.
The Islamic perspective
Love between husband and wife is good and honoured by God (﷾). But this poem never claims to come from God (﷾), and it barely names Him. It gives no law and no prophetic message. It does not show the marks of a message sent by God (﷾).
The Song is a love poem that gives no law and no prophetic message.
God's (﷾) name appears in the Song at most once. Even that is only if one word in 8:6 is read that way.
An evangelical study Bible calls Solomon's authorship an open question.
The Qur'an speaks of married love with warmth, as a sign of God (﷾).