In view of the physical evil and misery prevalent in the world, the Apostle attributes a human consciousness of pain to the rest of creation. It groans and travails together, i.e., every member of it in common with its kind. The idea of travailing, as in childbirth, has reference to the future prospect of joyful delivery. This consciousness of pain and imperfection has been continuous and unbroken, nor will it cease until an end is put to it by the Coming of Christ.
[Ellicott's Commentary for English Readers]

John 16:21 ... A woman when she is in travail hath sorrow, because her hour is come: but as soon as she is delivered of the child, she remembereth no more the anguish, for joy that a man is born into the world.
Romans 8:22-23 ... For we know that the whole creation groaneth and travaileth in pain together until now. And not only they, but ourselves also, which have the firstfruits of the Spirit, even we ourselves groan within ourselves, waiting for the adoption, to wit, the redemption of our body. ❤