>>80115396Enchanting tables give random enchantments with the use of XP and Lapus Lazuli. Building bookshelves around the enchanting table gives it more power, potentially giving you better enchantments.
Personally, I prefer the use of enchantment books, it's less random that way, as you get to pick which enchantments get applied