In the books and movies, the marauder's map only reveals it's true information for someone who knows the password. If the books in the restricted area of the library are so dangerous and thus forbidden to young students, why Dumbledore did not put a spell on the books so that they will not show their contents unless the reader knows a specific password? The books claim that Dumbledore is one of the greatest wizards of the world: thus he probably knew, or could invent a spell like that.
I suspect that Dumbledore was not interested in making it impossible for students to access the forbidden books. If he really didn’t want them reading the books he could have just removed them from the library.
Indeed, even the books about Horcruxes which he did remove from the library were not placed under any extra security.
I believe this is because of Dumbledore’s educational philosophy. He believed that anyone who had enough skill and determination to do something had a right to do it. He put enough barriers to repel the average student, but if a student was able to get past the barriers then Dumbledore would have wanted the student to be able to read the books.
In fact, this is essentially what Hermione says in the beginning of Deathly Hallows when explaining how she got the Horcrux books:
Anyway, if he really didn’t want anyone to get at them, I’m sure he would have made it much harder to –
Harry seems to have recognized Dumbledore’s philosophy way back at the end of Philosopher’s Stone:
”No, it isn’t,” said Harry thoughtfully. “He’s a funny man, Dumbledore. I think he sort of wanted to give me a chance. I think he knows more or less everything that goes on here, you know. I reckon he had a pretty good idea we were going to try, and instead of stopping us, he just taught us enough to help. I don’t think it was an accident he let me find out how the mirror worked. It’s almost like he thought I had the right to face Voldemort if I could.
Interestingly, this character trait seems reminiscent (minus the killing at the end) of that which Dumbledore described in Voldemort at the end of Half-Blood Prince:
“I’m sorry, Harry; I should have said, he would not want to immediately kill the person who reached this island,” Dumbledore corrected himself. “He would want to keep them alive long enough to find out how they managed to penetrate so far through his defenses and, most importantly of all, why they were so intent upon emptying the basin. Do not forget that Lord Voldemort believes that he alone knows about his Horcruxes.
I think the answer is either that the passwords on the books would be so insecure they'd be pointless, or they'd be so impossible to maintain, it'd be untenable.
The books are not intended to be completely inaccessible to students; they are merely restricted to those students that obtain a teacher's permission. Any password would have to be shared with any student who obtained permission. Of course, then the password would only be as secure as the least trustworthy student to receive the password. Worse, because the password is spoken, a well meaning but careless student could easily leak the password.
The problem becomes even worse if all the books have the same password, or the passwords are rarely or never changed. Then it would be even more likely that the password would be leaked by someone. But imagine if the books had unique passwords that regularly rotated. It would quickly become impossible for anyone to manage without writing the passwords down, and written passwords can be easily stolen. And even then, there's surely enough books that managing all those passwords would be difficult.
Compare with the Maurauder's Map, which only ever had a few owners that knew the password. And even then, it was still foiled by the twins, who had discovered it and the password without being told about it. There are even multiple other incidents in the books where passwords are foiled, like when Sirius Black uses Neville's written password list to get into the Griffindor common room, and when Harry just guesses the password to Dumbledore's office.
In conclusion, it makes sense to protect the Maurauder's Map with a password since most adults wouldn't be bothered to try to figure it out, and confiscate it without bothering, saving the owners from a worse punishment, but with a library full of books, it seems simpler and just as effective to just have a librarian supervise them.
But then, how would Harry, Ron, and Hermione have gotten into so much trouble, er, saved the school so many times?
Seriously, it's likely Dumbledore or some other wizard could have produced a spell requiring pass phrase before certain books could be opened -- after all, a group of students produced the Marauders' Map. But it would be an inconvenience for adults doing legitimate research, and surely wouldn't keep students out for long without continually changing the pass phrase (increasing the inconvenience factor). An Age Line would also keep students who had legitimate permission to access certain materials away, and have to be removed and reset for advanced students -- and Hermione did have such access at least once that I recall.
Instead, the Hogwarts library depended on the same methods Muggle libraries use to protect rare documents and "adult" subject matter -- alert librarians (who, being human, are imperfect and can be fooled), secrecy (that is, not publishing a list of what books might be in the restricted stacks where children can access it), and the tendency for most people to follow the rules (there wasn't that much traffic in the restricted section of the Hogwarts library, after all).