Lines: The maximum number of lines of potential an item can have is 3. The minimum is 2. You can increase the number of lines ONLY with Premium Miracle Cubes, and it is NOT guaranteed. Note that Legendary Rank items cannot be cubed with PMCs, and thus you cannot increase their lines.
Rarity: The order from least to greatest is Rare -> Epic -> Unique -> Legendary.
Legendary Items can achieve the highest stats on the potential lines, but require Cubes that cost 1.8k NX rather than 1.2k NX. These are called "Super Miracle Cubes" (SMCs), and, while they can be used on any rarity, the regular Cubes cannot be used on Legendary rank items. Note this also applies for Premium Miracle Cubes, so make sure you make your end-game item 3-line before trying to obtain Legendary tier.
It is extremely hard and not-worth-your-money to try to get 3 Legendary lines; it is (theoretically) possible, but just never happens. Most of the time you will settle for one Legendary line and 1 Unique line (21% at tier 3), though occasionally you'll see 1 Legendary and 2 Unique lines (30%@Tier3). If you're not planning to spend hundreds or even thousands of dollars on this game, I highly recommend you leave your items at Unique; getting to Legendary rank on any item is rather unreliable from what I've seen on other forums.
Regular Miracle Cubes (Cubing): cubes reset the potential of any item that is Unique rank or lower back to hidden. This means you can "reveal" it again, and it will have different potential stats. Regular cubes do not increase the number of lines an item has. If it has 2 lines, it will always have 2 lines as long as you cube with regular cubes. Upon reveal, it is possible your item will go up in rarity (up to Unique only!), but it is not possible to go down. Therefore, an Unique item will always be an unique item using these cubes.
Premium Miracle Cubes: These work exactly like the regular ones, but have a 25% chance at adding another line on 2 line items. There is discrepancy as to whether they increase the rarity of the item more often than regular cubes, but it is, as of now, unconfirmed.
Super Miracle Cubes: SMCs can be used the same way as regular cubes, on any potentialed item; they reset the potential the same way. The difference is that there is a (low) chance to get your item to Legendary rank (the highest rank), which will mean you can obtain some really nice stats on there. The downside is that you cannot use any other type of cube on Legendary items. Yes, once Legendary, you can ONLY use SMCs on the item to change its potential. These cubes are supposed to raise the rank of your item at a higher rate than regular Cubes, but it's unconfirmed because of the horrible RNG that Maplestory uses.
Equipment Enhancement: These scrolls have a chance to add random stats to your item, as long as the item has 0 slots. This means you can use EEs when you have 0 slots Unhammered, 1 hammered, or hammered twice.
The chance for it to work decreases as you use more of them on the same item.
If it fails, the item is guaranteed to blow up. You can prevent the explosion with a Shielding Ward, which is available occasionally (11k nx per though).
Regular EE scrolls start at an 80% success rate and decrease by 10% for every success.
Advanced EE scrolls start at a 100% success rate and decrease by 10% for every success.
Most people will not use these on Armor or Accessories as they have a notorious reputation for breaking things; however, they will use them very commonly on weapons, because they guarantee to add attack on weapons.
EEs add more attack as the attack of the weapon increases. I believe if the weapon has an attack from 100~149 an EE will add 3 ATT, from 150~199 it will add 4 ATT. 99 and below will only gain 2 attack from EEs, while weapons with 200+ ATT (yes, this is possible) will gain a whopping 5 ATT from every star added. This also applies to Magic Attack, scaling exactly the same.
Note that the stats added by EEs on other equips (EXCEPT GLOVES) are +STAT, HP, MP and the like, never ATT (to my knowledge). Gloves, on extremely rare occasions, have been known to gain attack through EE scrolls.