Genesis 2 has often been put at odds with Genesis 1. A long list of skeptics have claimed that the content is contradictory in places, especially when it comes to the timing of the events it recounts. Other scholars have argued that stylistic differences indicate that the chapters were written by different authors as parts of entirely separate creation accounts, and that these were later forced together in Genesis.
So how do we answer this while also affirming that “every word of God proves true” (Proverbs 30:5) and that Moses was the sole and inspired author of the Pentateuch (apart, of course, from the description of his death in Deuteronomy 34)?
The ESV Study Bible provides a helpful answer that accounts for both of these convictions:
The panoramic view of creation in ch. 1 is immediately followed by a complementary account of the sixth day that zooms in on the creation of the human couple, who are placed in the garden of Eden. In style and content this section differs significantly from the previous one; it does not contradict anything in ch. 1, but as a literary flashback it supplies more detail about what was recorded in 1:27. The picture of a sovereign, transcendent deity is complemented by that of a God who is both immanent and personal. The two portrayals of God balance each other, together providing a truer and richer description of his nature than either does on its own. In a similar way, whereas ch. 1 emphasizes the regal character of human beings, ch. 2 highlights their priestly status.
(Note on Gen. 2:4-25)
Pentateuch scholar John Sailhamer has a similar take on it (I do not agree with all he says about Creation, but he is helpful here):
It seems apparent that the author intends the second chapter to be read closely with the first and that each chapter be identified as part of the same event. Thus the author explicitly retuns to the place and time of chapter 1 at the point where he links it to chapter 2: “When the Lord God made the land and the sky” (2:4b). It is likely that the author’s central theological interests in chapter 1 would be continued in chapter 2 as well—the theme of humanity’s creation in the “image of God.” Thus we may expect to find in chapter 2 a continuation of the theme of the “likeness” between humankind and the Creator. (The Pentateuch As Narrative, 97)