Without magic, 600 feet, a sniper with a long bow
A long arc has a range of 150/600 feet, and the feat Sharpshooter (. PHB, p 170) includes this benefit:
Long-distance attack does not impose disadvantages on your ranged weapon attack rolls.
This means that you can perform a ranged attack against a target of up to 600 feet without disadvantage. I don't know any class or similar characteristics that allow you to increase the range of your ranged weapon attacks. This would be "always on", as long as it has arrows.
With magic, 2 miles, a master magician / sorcerer in the know with the distant metamagic spell that casts any distant spell
This article introduced the arcana Arcana disinterred tradition of Lore Mastery for wizards, including the following feature class:
Alchemical Foundry On the sixth level, you learn to increase spells in several ways. When you cast a spell with a spell space, you can spend an additional spell space to increase its effects for this cast, mixing the magical raw material in your spell to amplify it. The effect depends on the spell space you spend.
An additional second level spell space can increase the spell's range. If the spell's range is at least 30 feet, it becomes 1 mile.
Any remote spell with a range of at least 30 feet, say fire bolt, then you can make a distance attack roll to a target up to a mile away, assuming you have a clear path to the target and a way to see them at that distance (for example, by multiclassing in Totem Barbarian to get the Eagle from level 6 totem). This works as long as you have second level spell spaces remaining.
If you multiclassified in sorcerer to get the spell metamagia away, it says:
When you cast a spell that has a range of 5 feet or more, you can spend 1 point of sorcery to double the range of the spell.
This can be doubled to 2 miles. This is possible only if you have sorcery points to spend on metamagia.
Alternatively, with magic, 2 miles and 20 feet, Sorcerer with distant spell metamagia or any spellcaster with Spell Sniper feat casting meteor swarm
If we don't need it to be an attack roll specifically, then meteor swarm It has a range of 1 mile and affects a radius area of 40 feet, so if launched at a maximum distance, it could damage a target that is 1 mile and 20 feet from the launcher.
Then, I could increase this range to 2 miles, either by using the distant spell metamagia mentioned above, or by having the spell sniper feat (PHB, p. 170), which says:
When you cast a spell that requires a ranged attack roll, the range of the spell doubles.
Doubling the spell's range allows you to damage a target up to 2 miles and 20 feet away. This is possible only if you have level 9 spell slots to use and spell points to spend on metamagia (if you go with that option to double the distance; the Spell Sniper feat, however, is "always active") .