The rarity system is item description based only and does not change any gameplay mechanics.
Some official and custom items have a quality which indicates the rarity or nature of the specific item.
This feature has been introduced with the Legendary Part1 Update back in July 2016 and is supposed to help players, especially beginners, to get a feeling for rare items.
Masterwork are better than simply common and not that easy to get
Rare items may be hard to get and equals quite some worth
Exotic items are supposed to be special by itself or because of their source and can be either strong or weak
Ascended items count to the strongest ingame content there is or may be related to it
Legendary equipment will always have the same relative stats as the highest quality available for the item type. Currently, the only legendary items available are headgears and crafting materials related to them which equal the power of an ascended gear. These may offer special visual or item effects.
Currently available Legendary equipment: