With a tavern, make a room like you would for one of your dwarves, and designate it as a room, but don't give it to a dorf. Assign it to the tavern with the [l]ocations option, and select the tavern. One of your long term residents, like mercenaries and performers, will now live in that room. You should add a small drink stockpile to the tavern, and produce some instruments, mostly produced in the craftdwarfshop but other shops can be involved. Assign a tavernkeeper and a performer when one joins, and BAM! good working tavern. Some statues and smoothed floor for enjoyment, letting people who come to drink and party also get more happy thoughts.
A temple dedicated to one god has no effect on if the person prays or not, so having them dedicated to one god is pretty pointless, unless you want to set up a religious caste system, such as giving rainbow worshipers crappy temples, and war worshippers epic temples that make the king jealous.
The library is for those dwarves who never do anything around you fort, send a couple peasants there as scholars and instead they'll stand around discussing things and arguing and once a season or so writing if you give them scrolls and quires. You'll get foreign scholars appearing too, and they'll read and discuss and write as well. You get to keep the books and scrolls they write, and then your scribes can make copies. If you make the scrolls and books out of nice material, these copies make a pretty decent trade good, since they'll have the value of: the sheet, the thread used to bind the book, the book binding, and the writing, in the case of books, and the roller, the sheet, and the writing, in the case of scrolls, all with a quality meter increasing price. If you get a masterfully written masterwork roc quire, masterwork candy book binding, and masterfully black dyed GCS binding, studded with emeralds and sapphires and rubies, this book can buy you anything you want.
But you could also just keep the books around for your people to read for happy thoughts.