There are a million ways to do that, like not collecting data in the first place unless a user opts-in to your research group for example.
But companies chose the most user-hostile one intentionally. Essentially forcing everyone to give consent anyways (just click the big bright “consent” button!)
The fact that you’re able to maintain any amount of privacy at all on the internet is thanks to the EU, you can decline the pop-ups. If it wasn’t for that, then you wouldn’t even know when companies were abusing your data in the first place.
It's why EU simply can't produce anything useful at all because any European with a spark of entrepreneurial spirit goes to USA to start their company.
It may be a second order effect, but good governance means considering second order effects.
Edit: As pointed out by others in response to your comment, the same industry who decided to act like petulant children and take the most user-hostile approach - the one I'd assume you're lamenting - in reaction to the GDPR even though they didn't have to.
Whenever you bump into such user-hostile and annoying mechanisms, it is not the fault of the EU law but the service. They make it that way on purpose, precisely so you blame the wrong people (i.e. not them) and have you give up from exhaustion.
It was not the EU that “ruined the internet”, it was all the websites hungry for your data above all else. They “comply” in the most spiteful manner possible by design.
In most cases they rely on the fact that there are so many websites that someone else will get fined.
It's the endless capitalistic greed and urge to monetize every single mouse hover and click that has ruined the internet.
Advertising. It's advertising that has ruined the internet. It's advertising that created this surveillance dystopia, enabling businesses and governments, large and small, to exploit you and your loved ones. Not the EU. Advertising.
GDPR is just a tiny bandage on the thumb of an encephalitic newborn, infected at birth with an opportunistic pathonagen. That pathogen is called Advertising.