The Archery Fighting Style (PH 72) gives +2 to hit. Adding in a magic weapon +3 and magic ammunition +3 gives a whopping +8 bonus to hit in addition to the Dexterity and proficiency bonus.
On this site the highest standing AC without cover is listed as 35 (40 so long as you have spell slots to burn and can cast spells since shield happens before you get hit): What is the highest possible AC?
This means that to-hit bonuses need to be at least +21 or more to hit on anything other than a natural 20.
So an Dexterity-based ranged attacker with level 17 and 22 Dex can only get +20 to hit when needed (Assuming no more than one Manuals of Quickness of Action is found per party during the campaign).
Melee can get weapon +3, and +9 (if you get an extremely rare legendary) if belts are allowed (this Sane Magic Item Prices list doesn't even allow them). This leaves Strength-based melee at +18 (at level 17 or higher) with no hope of improving it (unless finding at least 5 Manuals of Gainful Exercise, but let us assume no more than one is found by a party per campaign). This still leaves melee with 2 less to-hit than ranged (and you of course have to be able to get up close first to even take a swing).
Are there any bonuses I'm missing? It seems a character that did a Min/Max AC build would only need to worry about natural 20's in order to get hit.
Note: In original post I erroneously listed Bracers of Archery as giving +2 to-hit instead of the +2 to damage. Thank you to those that left comments for pointing this out.