What kind of archer? The mobile archer? The sniper archer? All out DPS archer?
IMO rangers are fine but they are kinda bad at doing archer things (unless we are talking a spelless ranger). Hunters mark has limited range to activate.
(snip)
The second best is a rogue. .
So some elements that make a good archer are...
- Supporting Feats: Sharpshooter being the most important by adding damage and negating range/cover penalties. Crossbow Expert follows if you're into crossbows. Elven Accuracy is niche but could be helpful if you're shooting a lot with Advantage (from stealth, for example).
- Attacks: More attacks means more damage, especially when combined with SS. At least 11 levels of Fighter to get 3 attacks for an Attack action is very nice. Also Action Surge and similar action boosters are helpful. Xbow 2-weapon style increases rate-of-fire as well.
- Accuracy: Attacks are only effective if they actually hit. Although you'll hear comments that the -5 to hit on SS is a mild nuisance, it is a significant penalty that you'll want to shave as much as possible. Archery Fighting Style is a must and to-hit enhancements like Precision Attack, a +x magical weapon, Bless and others improve your ability to put damage on target. Shooting with Advantage also helps, so good stealth capabilities and other situations that can confer that are good.
- Damage: The reason you're shooting in the first place. With high rate-of-fire the SS bonus is your bread and butter. Additional base damage from a high Dex and magical weapon bonus is good, too. Then there's bonus damage from abilities like Sneak Attack, Hex, Colossus Slayer, Hunter's Mark and the like which are always good to have, especially for Crits. Try to make sure the minimum damage from each of your shots is striking for at least 20hp. Also a magic weapon is imperative at higher level to ensure you can effect all targets.
Variant human Battlemaster Fighter with 3-5 levels of Hunter Ranger. Pick Sharpshooter and Crossbow Expert feats. Try to gain advantage on as many attacks as possible. When you have it, use -5/+10 and use Precision maneuver to turn near misses into hits.I can't decide between Fighter or Ranger and I can't help feeling like the "best archer" should have a some Rogue levels for sneak damage.
I'm thinking 5-8 levels of Ranger or Fighter and then Rogue our from there.
Best archer is basically Ranger until level 11 when the fighter is competitive. You can use the -5/+10 part of SS on horde breaker, volley and the level 5 ranger spell that grants +2 attacks. Basic build hunters quarry+ colossus slayer> fighter until level 11.

(Dungeons & Dragons)
Rulebook featuring "high magic" options, including a host of new spells.