For a long time, I made the intuitive assumption, which is that they request this simply so that people do not put things back in the wrong place. Putting things back in the wrong place is an easy mistake to make, since even if you think you remember where you got a book from, most libraries have a lot of shelves in them, and even if you remember the exact shelf that you got a book from, it's not always easy to remember exactly which two books it was between when you took it.
Of course, there are various precautions that could be taken, the simplest and most obvious of which is to simply remember which two books your book was between. If you're forgetful or if you're taking several books off the shelf at once, you could be uncommonly diligent and take photographs of the books before you remove them so that you will be able to reference exactly what they looked like before you removed them from the shelves. All of this is entirely possible, but it's safe to say that essentially no one actually does this, and even if someone did, the library needs to have a simple rule that is easy for everyone to understand and follow, so even if there is a small minority of people who could be counted on to consistently put things back where they got them from, it would be impractical for the library to put up signs saying "Please take photographs of all books before you remove them so that you can put them exactly where you took them from, or else write down the names of the two books that surrounded your book before you removed it so that you will know exactly where to put it," so they simply go with the much simpler "Please do not reshelve items." In some ways, it sounds like the librarians are treating people as if they're stupid or irresponsible, but the problem is that this is precisely the case; there are a great many stupid or irresponsible people in the world.
An added wrinkle to the problem is: What if someone else returns a book that happens to end up between the two books that your book was previously between? When you go back to the shelf to return your book, should you put it to the left or to the right of the book that was not there before? If you actually know how to read the labels on the spines of books and understand the Dewey Decimal System, then you could, in theory, discern where your book should be returned to, but once again, few people actually can be relied upon to consistently interpret the book labels correctly, and so in the interests of making a simple rule that can be applied to everyone, the library needs to make the assumption that everyone is stupid.
There is, however, a second reason why libraries sometimes ask patrons to not reshelve items. The reason is that they often track which items are used by people, even if those items are not checked out. In most libraries, more books are read by people while they're in the library than actually borrowed to be taken out of the library. This means that the library has no way of tracking which books people are reading unless people leave the books on reshelving carts; this way, librarians can compile lists of these books before putting them back on the shelves. There are, in turn, two reasons why tracking "used but not borrowed" books in this way is important for libraries:
1. Every library must make decisions about what books to stock and what books to not stock. By keeping records of what kinds of books are most used by library patrons, the library can extrapolate more accurate data about what books people will want to use.
2. Most public libraries need to justify their budgets since they're funded with public money, and it is important for public libraries, in this regard, to be able to reflect just how many people used the library. If many people use the library but this usage is not reflected in the library's statistics, it may appear that hardly anyone uses the library, which results in budget cutbacks, which means less new books in the library, less librarians, shortened operating hours, and possible closure of the library altogether.
I'll admit that I don't like the idea of my reading habits being tracked; while I understand that this information is anonymous (since the library can only record that someone pulled a book off the shelf, not who that specific person was), I rather dislike the idea of a society in which everything people do is tracked. Furthermore, I do not wish to inconvenience librarians (since the ones who actually work at menial tasks like reshelving books are usually students paid minimum wage, and in some cases volunteers who work for literally no money), so I usually instinctively want to save them some effort by putting my own stuff back.
There's also a certain gray area with regard to "using" books, as well: Suppose you simply take a book off the shelf to flip through it for a few seconds, but do not actually sit down to read it for longer than that. What are you supposed to do with the book then? Does this count as "using" the book? Since you're standing directly in front of the place where you just picked up the book from, chances are excellent that you'll still be able to see the specific gap that the book was in. If I, as a library patron, am expected to drop every book I glance through onto a reshelving cart instead of just putting it back where I picked it up from 10 seconds ago, the reshelving cart might as well be a wheelbarrow that I tip the entire shelf into. Okay, perhaps that's a bit of an exaggeration, but I'll confess that since I typically pull a great many books off the shelves when I'm in a library, I'll just put them back if I am only looking at them for a few seconds, and I think this is fairly in the spirit of what librarians want us to do anyway; I believe that we are only expected to put books onto a reshelving cart if we in fact spent a significant amount of time with the book, as in more than a minute or two.
To make things perhaps more confusing, some libraries request the exact opposite, and indeed post signs saying something like "Please reshelve materials when you are done with them." The effective policy is really set on a per-library basis, and if you're not certain whether you should reshelve items when you're done with them or not, you can ask one of the librarians. Librarians are probably one of the few types of "customer service" people who rarely get annoyed by people asking them questions, partly because libraries usually do not have a great many people using them, and also because most librarians are usually quite passionate about books and love to talk about books, given the chance. An added benefit is that librarians are usually intelligent women, and increased contact with intelligent women is a plus as far as I am concerned.