Placing bookshelves near your enchantment table will allow you to use higher level enchantments. Here's the optimal bookshelf layout to maximize enchantment levels:
You need a 5x5 ring of bookshelves, two meters high, with the enchantment table in the middle. There can be 2 bookshelves missing anywhere in the ring. There must be empty space between the table and the books.
There are 32 positions that the code checks for bookshelves, but the bonus for having bookshelves is capped at 30. This is why the gap is allowed without affecting enchantment levels.
With 30 books in range, the maximum level you can get is 50.