There are a number of exceptions to copyright, and at least in the US, the supreme court's understanding of "transformativeness" applies to chatgpt and other similar tech.
The relevant quote, originally written in 1990 and cited in 94, is thus:
"
[If] the secondary use adds value to the original--if the quoted matter is used as raw material, transformed in the creation of new information, new aesthetics, new insights and understandings--this is the very type of activity that the fair use doctrine intends to protect for the enrichment of society.
"
We've wandered into uncharted legal territory with only a few light posts guiding the way. Nothing about this is settled or obvious.