Enchantments have a configurable rarity. A rarity contains several values: The minimum xp level required to get the enchantment from an enchanting table, the percentage chance of getting the enchantment above that level, the percentage chance of a villager having a trade for that enchantment, and the percentage chance for an item in a loot chest to spawn with that enchantment.
All values are completely configurable, and you can create, edit, and delete as many rarities as you want.
Means of obtaining
By default, normal, special, and artifact enchantments are available from Enchanting Tables, Villagers, and Loot Chests. Curse enchantments, by default, are only available from Villagers and Loot Chests, just like in vanilla.
Levels are calculated based on their cost. If you get an enchantment from 1 xp level or 1 emerald, it will probably be a level 1 enchantment. Of course, it is possible to get above this at a low cost but it is rare. This is designed to be as similar to vanilla as possible.
Loot chests will generally contain higher level enchantments. This is also designed to be like vanilla, where enchantments in, for example, and end city will have a relatively high level.