In a Scandal in Belgravia Sherlock spends a whole episode trying to guess/find Irene Adler's phone password. But in other episodes Sherlock finds almost no trouble in finding others' passwords, like he does in The Hounds of Baskerville and in The Lying Detective. So why did Sherlock have so much difficulty in guessing Irene Adler's password?
The reason that Sherlock can figure out other people's passwords and passcodes is because a lot of people, particularly ones who are less tech-savvy, base their passwords on things that are easy for them to remember. This often includes common words and names of people close to the person in question. So for many of these kinds of people, it's pretty easy to guess that their password might be their wife, or daughter, or pet's name. If it's a system that enforces stronger password rules (e.g. must include numeric digits), then it's still not hard to guess a few simple variations (e.g. "password1", wife's name followed by wedding year, etc).
In the case of Irene Adler, she is made out to be one of the few people on a similar intellectual level to Sherlock, along with Mycroft and Moriarty. Additionally, it is not immediately obvious whether there is someone, or something, that is important enough to her that she would use it as her password. That said, throughout the episode she is shown to be playing with Sherlock and enjoying seeing the difficulty he has in reading her (as demonstrated by the many "?" annotations displayed when he tries to analyse her when they first meet), so it is reasonable to expect that her password has been set to something that should present a challenge to him but not be impossible to guess (so it's probably not going to be completely random).
As it turns out, the challenge is in noticing that Irene is, in her own way, obsessed with Sherlock himself. He is, in essence, the one chink in her armour, and discovering that is then the key to knowing how to unlock the phone.
 Whenever there's a major password database breach, and people do analysis of the leaked passwords, the most commonly used password is frequently "password" or some variant.