Note: This answer was written when the question was still asking for "the maximum distance a creature can attack from"; now that the question has changed to "the maximum distance a creature can cause damage from", this answer is somewhat limited to attacks. Rather than update my answer, I'll leave it in its current form in case anyone is interested in "attacks" specifically; otherwise, see Medix2's answer for the maximum distance one can cause damage from.
Without magic, 600 feet, a Sharpshooter with a longbow
A longbow has a range of 150/600 feet, and the Sharpshooter feat (PHB, p. 170) includes this benefit:
Attacking at long range doesn't impose disadvantage on your ranged weapon attack rolls.
This means you can make a ranged attack against a target up to 600 feet without disadvantage. I am not aware of any class features or similar that would allow you to increase the range of your ranged weapon attacks. This would be "always on", so long as you have arrows.
With magic, 2 miles, a Lore Mastery Wizard/Sorcerer with the Distant Spell metamagic casting any ranged spell
This Unearthed Arcana article introduced the Lore Mastery arcane tradition for wizards, which includes the following class feature:
Alchemical Casting. At 6th level, you learn to augment spells in a variety of ways. When you cast a spell with a spell slot, you can expend one additional spell slot to augment its effects for this casting, mixing the raw stuff of magic into your spell to amplify it. The effect depends on the spell slot you expend.
An additional 2nd-level spell slot can increase the spell's range. If the spell's range is at least 30 feet, it becomes 1 mile.
Any ranged spell with a range of at least 30 feet, say fire bolt, then you can make a ranged attack roll at 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 (such as by multiclassing into Totem Barbarian to get the level 6 Eagle totem). This works so long as you have 2nd-level spell slots remaining.
If you multiclassed into sorcerer to get the Distance Spell metamagic, which says:
When you cast a spell that has a range of 5 feet or greater, you can spend 1 sorcery point to double the range of the spell.
This can then be doubled to 2 miles. This is possible only if you have sorcery points to spend on the metamagic.
Alternatively, with magic, 2 miles and 20 feet, Sorcerer with Distant Spell metamagic casting meteor swarm
If we don't need it to be an attack roll specifically, then meteor swarm has a range of 1 mile, and affects a 40-foot radius area, so if cast at maximum distance, it could cause damage to a target that it 1 mile and 20 feet away from the caster.
Then you could increase this range to 2 miles, either by using the Distant Spell metamagic mentioned above. 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 9th-level spell slots to use, and sorcery points to spend on the metamagic.