Mary as “Queen of Hevean” is an ancient address to Mary used in prayer that dates back to at least the fourth century. The imagery of Mary as queen of heaven was very popular in the Middle Ages.
Its theological basis derives from the notion of Jesus as King. The New Testament uses the image of a king to describe Jesus (Matt. 21:5; Luke 1:32; John 12:12-15; Heb. 1:3, 8). In Israel the mother of the king held the role of queen mother. In essence she held a role of great prominence in the court and the king would usually acquiesce to her wishes (1 Kings 2:20; Jer. 13:18; 29:2). In 1 and 2 Kings the kings are almost always listed with their mothers and are depicted as advising their sons.
As Jesus is king that makes Mary his queen mother according to Jewish tradition. Getting to the king through the queen mother is a natural thought and spurred Christians to ask Mary to intercede with Jesus on their behalf. Mary’s queenship is a share in Jesus’ kingship.
For further reading: Pius XII’s Ad Caeli Reginam