Check out this if you have questions on rarity scaling:
https://xpoff.com/threads/weapons-and-how-scaling-works.74267/#post-1069472
I wonder why people get different results on different classes as to how rarity affects their dps.
Essentially how it works, is that the scaling of damage still takes raw damage and weapon speed into account. However, the majority of improved scaling comes from rarity once you reach the epic rarity and upwards.
So, with this in the back of our heads, we now look at the ilvl scaling as well. Any item, no matter the rarity, will be scaled to the appropriate ilvl of each bracket. That ilvl is generally set by heirloom ilvl. So, whatever ilvl your heirloom has at the max lvl of your respective bracket is the scaled ilvl of each piece of gear.
Now we combine these factors. Rarity, which generally is the most important factor at an epic rarity and above, plus the raw damage of the weapon, plus the weapon speed, plus the actual ilvl scaling of the weapon.
The reason as to why epic weapons (especially the ilvl one epics for the lower level brackets) scale so well, is because they have pretty good raw damage for their respective ilvl. That now scales with their increased "pseudo-ilvl" that they will receive while equipped inside instanced PvP + rarity bonus.
It's pretty weird. Even more weird if people start to get different numbers where heirloom weapons surpass epic weapons.