Villager Help?

Guys, I see screenshots from some players who are near end-game, with a bunch of villagers in strange contraptions. So, I have questions:
1. What are they? Are people trying to farm villagers or something?
2. Why? What resource do villagers give, that's so important?
3. If I should make some sort of villager farm in my base, what's the best way to keep them safe from anything that goes bump in the night?

Sorry if this sounds like rookie stuff. I promise I've been playing this modpack for over a year, I just don't look at guide often, LOL!