I decided to attempt to figure out what the highest possible bonus to a single attack roll, given the proper magic items and spell buffs. From what I could tell, the best way to go about this would be with a 20th level ranger, given the conditions below:
20th Ranger, 20Dex + 20Wis, target is a favored enemy
+6 profiency bonus
+5 dexterity ability score modifier
+5 foe slayer feature
+3 magic bow
+3 magic arrow
+2 archery fighting style
+1 ioun stone mastery
That gets me to a +25 to hit, but I feel I could still go further... Say the ranger was to receive a Bless spell (1d4) and a Bardic Inspiration Die from a 17th or higher Bard (1d12), then proceeded to roll max on both dice and use them for his attack roll, yielding an additional +16 attack roll bonus, that would cap out at a whopping +41 to hit.
That said, given RAW rules regarding ability score caps and attuned magic items, as well as spells and items found in official material only, what other spells, features, magic items, and buffs from other creatures would add to this hypothetical attack roll modifier?