Comment by proberts
The short answer is that CBP has the right to ask to see your electronic devices and you have the right to refuse but if you refuse (and you are not a U.S. green card holder or citizen), CBP likely will deny you admission and send you home.
I had a friend who was asked to unlock her phone, and she did, and then… they did nothing. They watched her do it and moved on to the next question.
Seems like asking someone to do this is just a good test to see the kind of individual they’re dealing with. It’s not practical to thoroughly search phones at scale and plus they know people can just have burner phones anyway. If you’re cagey and combative they know you’re a problem.