The Google Books case cited here allowed Google to show exact snippets (extracts) from the copyrighted books, hard to see how this is any different.
But Copilot doesn't exist to show you random code snippets for the sole purpose of showing them.
Using this copyrighted material to create derivative works is a completely different use case, and not covered at all by the Google Books ruling, or any other I'm aware of.
Google isnt making new books, or enabling people to make derivative copies; it is merely previewing a book.
Github search is a preview. Copilot is a copy/paste.
The research value actually turned activity that would be infringing into activity that was not infringing. Take away things like the ngram viewer and Google Books infringes.