Killing randomly spawned zombies at night is both dangerous and slow. Other methods - breeding animals, mining ores, smelting materials, fishing - builds up XP painfully slowly. Top level enchantment with the table requires 30 levels and uses up 3, that's 165 mobs to kill for first enchantment, and 34 mobs to recuperate from level 27 to 30. It's fairly hard to gather that much running at night and killing them as they attack you. For enchanting books, the top enchants may take up to 39 levels, and drain your levels to zero in the process. That's a whopping 350 mobs to kill, 1743 coal ore broken, or over half the levels obtained killing the ender dragon for the first time.
Trying to gather enough XP for a good enchanted set of gear using these methods takes too long. Players in fully enchanted gear aren't uncommon, many of them even trade the good gear for prices that definitely don't look like worth weeks of grinding. How might they manage to obtain the XP necessary for dozens or hundreds of high level enchantments quickly and easily like that?