Here is an account of a dream that Eliphaz the Temanite had:
“A word was secretly brought to me, my ears caught a whisper of it. Amid disquieting dreams in the night, when deep sleep falls on men, fear and trembling seized me and made all my bones shake. A spirit glided past my face, and the hair on my body stood on end. It stopped, but I could not tell what it was. A form stood before my eyes, and I heard a hushed voice: ‘Can a mortal be more righteous than God? Can a man be more pure than his Maker?’” (Job 12-17).
Later, God speaks to Job and says:
“For God does speak – now one way, now another – though a man may not perceive it. In a dream, in a vision of the night, when deep sleep falls on men as they slumber in their beds, he may speak in their ears and terrify them with warnings, to turn man from wrongdoing and keep him from pride, to preserve his soul from the pit, his life from perishing by the sword” (Job 33:14-18).
One function of dreams that come from God is as a warning. Take, for example, Nebuchadnezzar’s dream of a huge statue which was destroyed. Daniel explained that the dream had come for God as a warning of future events (Daniel chapter 2). In another dream Nebuchadnezzar saw a great tree that was cut down. It was a warning to the king to renounce his sins and turn from wickedness. Nebuchadnezzar failed to heed the warning and the prophecy came to pass (Daniel 4:19-37).
Joel 2:28 is a prophecy regarding a time when God would pour out His Spirit: “Your sons and daughters will prophesy, your old men will dream dreams, your young men will see visions.” The Apostle Peter testified to the fulfilment of this prophecy when the Holy Spirit came to the followers of Jesus who were gathered in Jerusalem for Pentecost (Acts chapter 2).
“In the past God spoke to our forefathers through the prophets at many times and in various ways, but in these last days he has spoken to us by his Son, whom he appointed heir of all things, and through whom he made the unvierse” (Hebrews 1:1-2).
The point here is that God has chosen to speak to humanity through Christ Jesus. That is why many people have dreams of Christ Jesus and have turned to Him in faith. God also speaks to humanity through his Word, the Bible.
You ask what is the function of dreams that are neither prophetic nor have visions of Jesus. In other words, what is the function of dreams that do not come from God? According to this article, the jury is still out: https://en.wikipedia.org/wiki/Dream#Function
Many hypotheses have been proposed as to what function dreams perform, some of which have been contradicted by later empirical studies. It has also been proposed that dreams serve no particular purpose, and that they are simply a by-product of biochemical processes that only occur in the brain during sleep.
My favourite dreams involve me flying like a bird, soaring up into the sky then sweeping down over trees and roof tops. Wishful thinking, I guess.