First is the Armor Rating, the big number you see on all armors. It is based on the item level and item rarity, it’s pretty simple for each rarity and level there is minimum and maximum value and a when item is created you get the value somewhere in between.
Next are the attributes, they are a bit more fun. An item can have up to three attributes but the exact number is based on rarity and level of an item. For example common item never has attributes, low level common and rare will have 1 attribute but they can have more on higher levels. The top attribute you’ll see on the list is what we call primary attribute and it will always be either firepower bonus, anomaly power bonus or health, chosen randomly on item creation. Bellow primary attribute you get up to 2 secondary attributes randomly chosen from the list when item is created, there is just a few of them but enough to have some variations in the items.
The base value of each attribute is based on item level, there is no rolling here. However attributes on items levels of their own, up to 6. So an item at level 10 can give +100HP if attribute is level 1, but it will give 110HP at level 2 and so on. The level of an attribute is rolled on item creation.
At this time you can’t change attributes on an item so of you want to have perfect combination you have to find perfect item, but you can level them up in crafting. When you scrap an item you get shards for one of it’s attributes, which one is indicated by special icon. Then you can use that shards to level up same attribute on different item. However when you level up an item you’ll loose some levels on the attributes, the values will remain more or less the same but because there is new possible maximum value to achieve the whole thing is shifting. This makes attribute leveling mostly end game activity but in my experience it can be helpful in some sections of mid game where you could use a bit of extra health but you don’t want to respec your damage focused tree. Additionally if you invest in upgrading an attribute it will also get an icon so you can recover some shards when scrapping that item.
Legendary items are exception to some of this rules as both mods and attributes are premade by designers.