I know it's bad form to quote yourself, but I thought some examples might help.
If the lock is an easily beatable DC -one which the PCs probably don't even need to roll for- the purpose is simply to slow them down. ...a dramatic hurdle if you will; something just to use up actions. In my mind, I'm likening the concept to some of the speed runs which some video games have.
Ok, so let's say there is a bomb ticking down, and it will soon explode. For sake of arbitrary example, we'll also say it's a negative energy bomb which will level drain you to death (if you're playing 3rd Edition) or will chew up enough of your healing surges (if you're playing 4th edition) to possibly kill you. You've already failed the attempt to disarm the bomb, so your only choice now is to get far enough away from it to survive before it explodes.
One of the paths away from the bomb is a long hallway which has several locked doors. All of the locks are very simple locks; so simple the DM says you don't even need to make a skill roll. However, you do need to still take the actions necessary to pick the locks.
In this case, the locks are simply there to slow you down and make the passage of time more dramatic. Can you get through all of the doors before the bomb explodes and kills you? Should you have instead attempted to take the shortcut which required you to risk running down a different hallway which had no doors at all, but was filled with traps?
If the lock requires a special key, the purpose tends to be to force you look for that key and direct you toward other areas of the game/world. The original Resident Evil games used this quite a bit. It's kind of like a softer and more passive version of railroading. It doesn't force you to go in a specific direction; often, you will have choices, but eventually you'll be directed that way. It's sort of like a traffic control device. A lot of DMs (myself included) might even still let you try to open the lock without the special key, but doing so will probably be far more difficult.
You're in a dungeon looking for the Codpiece of Vecna. It's a long forgotten artifact which you learned of after deciphering some old scrolls. It is rumored that it has powers which will help you win the affections of the princess. Delving into the dungeon, you discover that the Codpiece of Vecna is locked away in a demiplane, and, to summon it from the demiplane, you need three magic orbs which you will then place inside of an enchanted treasure chest which exists here on the material plane.
You come to a circular central chamber which has 6 (choices!) doors -which presumably lead elsewhere. In the middle of the chamber is a stone table upon which the enchanted treasure chest rests. Sticking out of the chest is an iron key which was presumably the key used to open the lock on the front of the chest. Attached to the key is a keyring, and upon that keyring is another dangling key which looks to be made out of ruby. You then remember the old man at the tavern saying you would need special keys to find each of the orbs; one would be ruby, one would be sapphire, and one would be made out of canary diamond.
Looking around the room, you notice that three of the doors are typical iron doors with one keyhole. You also notice that one of the doors is painted orange and has two keyholes. The other two are verdigis (green) and violet, and they both also have two keyholes. Noticing that there are two keys already in the room, you try both of them and discover that the iron key does not fit into any of the colored doors; the ruby key fits into one of the keyholes of the orange door and one of the keyholes of the violet door, but does not fit into either of the keyholes on the green one. You discover that the iron key does fit into all of the iron doors, but the ruby key fits into none of them.
Discussing what to do next, it occurs to the party that rubies are red and canary diamonds are yellow; yellow and red makes orange, so that must mean you need those two keys for the orange doors. It doesn't take long to then figure out that combinations of two colored keys match up with the colors of the doors. Only having one colored key, the party needs to seek them out. Each key is presumably found elsewhere in the dungeon; behind the iron doors.
If the lock is difficult to open, the lock itself is part of the challenge and not simply just part of the world. It's something you need to overcome to advance.
The party is being chased by a particularly vicious group of kobolds. Being low on HP, the party seeks a way to find refuge. The party rogue spots a nearby door, but it is locked. He believes he can get it open, but he needs time to do so. It's a difficult enough lock that the DM calls for a skill challenge consisting of 4 successful checks to get it open. The kobolds will be upon the party in 6 rounds.
In this case, the door itself is what you need to get by.
-----------------------------------------------------------------------------------------
Really, you could combine all of them into one adventure.
You're in a dungeon looking for the Codpiece of Vecna. It's a long forgotten artifact which you learned of after deciphering some old scrolls. It is rumored that it has powers which will help you win the affections of the princess. Delving into the dungeon, you discover that the Codpiece of Vecna is locked away in a demiplane, and, to summon it from the demiplane, you need three magic orbs which you will then place inside of an enchanted treasure chest which exists here on the material plane.
You come to a circular central chamber which has 6 doors and two hallways -one of the hallways being the way you entered the room from. In the middle of the chamber is a stone table upon which the enchanted treasure chest rests. Sticking out of the chest is an iron key which was presumably the key used to open the lock on the front of the chest. Attached to the key is a keyring, and upon that keyring is another dangling key which looks to be made out of ruby. You then remember the old man at the tavern saying you would need special keys to find each of the orbs; one would be ruby, one would be sapphire, and one would be made out of canary diamond.
Looking around the room, you notice that two of the doors are typical iron doors with one keyhole. Above both of the hallways are dwarven runes which one of the party members translates and tells the rest of the party that the runes say "exit." One of those hallways is (as mentioned) the one you entered the circular chamber from, and the other seems to be pretty obviously trapped, but you can see some light at the end of the obviously trapped tunnel. A third door is also iron, but it differs from the other two in that it has a barred window set into it, a cheap quality lock, and the same dwarven runes ("exit") painted on it. Looking through the barred window, you see that there is a line of similar doors at regular intervals further down the hallway, and you can also see some light at the end of the hallway; coming from somewhere beyond the final door.
You also notice that one of the doors is painted orange and has two keyholes. The other two are verdigis (green) and violet, and they both also have two keyholes. Noticing that there are two keys already in the room, you try both of them and discover that the iron key does not fit into any of the colored doors; the ruby key fits into one of the keyholes of the orange door and one of the keyholes of the violet door, but does not fit into either of the keyholes on the green one. You discover that the iron key does fit into all of the iron doors, but the ruby key fits into none of them.
Discussing what to do next, it occurs to the party that rubies are red and canary diamonds are yellow; yellow and red makes orange, so that must mean you need those two keys for the orange doors. It doesn't take long to then figure out that combinations of two colored keys match up with the colors of the doors. Only having one colored key, the party needs to seek them out. Each key is presumably found elsewhere in the dungeon; behind the iron doors.
Eventually, the party finds all of the colored keys. Using those keys, they then open each of the colored doors and find the orbs. However, upon returning to the central chamber, they find that the chest in the middle of the room is now closed and locked. Glowing sigils are now on the chest's lock. The rogue doesn't recognize them, but the party cleric makes a religion check and discovers that they are part of a curse/trap that helps to keep the chest closed when locked, and it prevents the iron key from working again. the rogue and cleric engage in a skill challenge to get the lock open; with the cleric using his skills to get by the curse and the rogue using his skills to get by the more mundane features of the locking mechanism.
Unfortunately, they fail the skill challenge, and now the sigils turn into numbers. The numbers begin to count down, and a beeping noise comes from the chest each time the numbers count down. The cleric gets some divine insight concerning the nature of what is going on, and he sees a vision of a negative energy explosion coming from the chest; killing the party. If the party hopes to survive, they need to get as far away from the chest as they can; as quickly as they can. One of the exit options is to go back the way the party came, but doing so will take too long; there's no light at the end of that tunnel for a while. One of the options is the trap filled hallway which seems to be the quickest route to daylight, but is also the most obviously dangerous. One of the options is the hallway with series of doors that have cheap locks; going that way is safer than the trap filled hallway, but is more time consuming.