1) Handover unlocked device, let CBP knuckle-dragger browse through it, in front of me, until they're bored and they hand it back. Get on flight. This is the best case scenario.
2) Handover unlocked device, CPB knucke-dragger takes it to back room where he may or may not download all contents and store it, enabling NSA to play seven-degrees-of-keven-bacon, Osama-edition, forever. That's the worst scenario, but very unlikely that anything comes of that.
3) Laugh at CBP knuckle-dragger, keep phone locked, miss flight, go to airport detention for an indeterminate amount of time until I give in and handover unlocked phone, be subject to scrutiny and "commentary" from CBP official, and maybe, get put on a list somewhere which will cause this to happen every time I fly.
This has never happened to me, and it probably never will, but if it does my plan is to refuse to unlock the phone and wait it out.
But OK, staying locked is a fine thing to do but most people would want to get on with their lives.
Yes, I personally know someone this has happened to. Also resulted in my own personal name/address/other info (amongst that of many others) also being demanded and hence provided to the government.
> Why on earth would anyone ever consent to this nonsense?
What would you do if you weren't a citizen and had a family to come back home to? Just be okay with being denied entry?
Because the government has more guns than you do.
The detailed legal answer is far more complicated than that, but it simplifies readily.