Brian Blount (Revelation: A Commentary, 225) summarizes the array of interpretations:
Some connect her with figures in Israel's or the church's past or future: Eve, the mother whose seed would bruise the head of the dragon/serpent (Gen 3:1-16); Mary, the mother of Jesus; or the heavenly Jerusalem as bride of the Lamb (19:7-8; 29:9-10). Others suppose a pagan or astrological connection: a queen of heaven like the Egyptian Isis, or the constellation Virgo. Still others hypothesize a corporate representation of God's people: Israel, who escapes the dragon/Pharaoh into the wilderness on wings of eagles (Exod 19:4; cf. Ps 74:12-15); or Zion, the mother of the persecuted people of God (Isa 66:7-9; 4 Ezra 13.32-28).
In my answers to a few other questions, I've pointed to the way the author of the Revelation borrows and adapts symbols, scenes, and idioms primarily from the Hebrew bible to form his book.
The symbols surrounding the woman come from a swath of texts in the Hebrew bible, but the connection between all of them is they are all concerned with Israel, Judah, or Jerusalem/Zion. Breaking down the individual symbols in Revelation 12:
A great portent appeared in heaven: a woman clothed with the sun, with the moon under her feet, and on her head a crown of twelve stars.
The specification of the stars as twelve in number brings us to Genesis 37.1-11. The final third of Genesis tells the story of Jacob (a.k.a. Israel) and his twelve sons, forefathers of the twelve tribes of Israel.
Genesis 37.1-11 specifically has one of the younger sons, Joseph, describe a dream he had: he saw a sun, a moon, and eleven stars bowing down to him. His family immediately recognized that the sun was his father (Jacob/Israel), the moon his mother, and the eleven stars his brothers. The implication that Joseph is a twelfth star was taken for granted by the first century; cf. Philo, On Dreams 2.113: he who saw this heaven-sent vision, thought that he was being worshiped by eleven stars, ranking himself among them as the twelfth.
The woman in Revelation 12 is wrapped in the symbols from Joseph's dream which were intended to represent Israel and all its people.
She was pregnant and was crying out in birth pangs, in the agony of giving birth.
Prophetic texts sometimes symbolize Israel, Judah, or Jerusalem/Zion as a woman suffering birth pains during periods of crisis or social upheaval. Examples include Isaiah 26.1,17-18 and 66.7-11, or Jeremiah 4.31. The revelator adapts this motif and specifically identifies her offspring as the messiah (combining imagery from Psalm 2 and Psalm 110).
Then another portent appeared in heaven: a great red dragon, with seven heads and ten horns, and seven diadems on his heads. His tail swept down a third of the stars of heaven and threw them to the earth.
The revelator borrows this from Daniel 8, another symbolic vision and combines it with the earlier use of Gen 37.1-11. In Daniel 8, the titular sage has a vision of a goat's horn throwing down stars and trampling them (Dan 8.9-10). An angel explains to Daniel that this vision symbolizes persecution befalling 'the people of the holy ones' (8.24), i.e. Torah-faithful Israelites.
and the woman fled into the wilderness, where she has a place prepared by God, so that there she can be nourished for one thousand two hundred and sixty days. [...] the woman was given the two wings of the great eagle, so that she could fly from the serpent into the wilderness, to her place where she is nourished for a time, and times, and half a time.
Here the revelator borrows very directly from Exodus 19.3-4: 'Thus you shall say to the house of Jacob, and tell the Israelites: You have seen what I did to the Egyptians, and how I bore you on eagles' wings and brought you to myself.'
'One thousand two hundred sixty days' is three and a half years according to the Hebrew calendar, rendered a second time idiomatically as 'time and times and half a time' (i.e. one and two and one-half). This comes from Daniel 7, though John reverses its meaning; originally it signified the period of persecution Torah-faithful Israelites would suffer (the same one mentioned in Dan 8), but John here uses it to signify a period in which Israel will remain protected.
Somewhat complicating the whole matter is John's adaptation of the Combat Myth that permeated Indo-European mythologies (see this answer). In particular, the revelator appears to have borrowed from a version of the Combat Myth well-known in the Asia region: the story of Apollo and Python.
The New Oxford Annotated New Testament comments:
The vision of the woman, the child, and the dragon is rich in symbolism drawn from the mythological traditions found in ancient Babylonia, Egypt, Greece, and Rome, as well as in the Hebrew Bible. One well-known version of the story tells of the goddess Leto, pregnant with Apollo, who is menaced by the dragon Python, who pursues her because he knows that Apollo is destined to kill him (Hyginus, Fabulae 140).
The Jewish Annotated New Testament:
The motif of the pregnant woman chased by the dragon, here and in vv.13-17, recalls the story of Leto (and her child, Apollo), pursued by Python. It is not surprising that a Jewish author from Asia Minor might draw out a vision rooted in prophetic oracles by means of regional mythology.
And GK Beale's commentary, The Book of Revelation, 624:
The version of this story best known in Asia Minor was that of the goddess Leto who was pregnant with Apollo, the son of Zeus. She was attacked by the dragon, Python, because he knew that her offspring had been appointed to kill him. But she was carried to a safe island by winds sent by Zeus. The god Poseidon hid the island under the water so that Python could not find the woman and her child. Four days after Apollo was born, he found the dragon and slew it.
In other words, John borrowed the specific shape of the Combat Myth as seen in the Apollo vs. Python story and replaced its 'pagan' elements with symbols assembled from throughout the Hebrew bible.
The broad consensus of critical scholarship is the woman represents Israel.