It really depends on what you want more in my opinion.
If there is a $40 game you dying to have but don't want to pay out of pocket for, then that makes sense.
Xbox Live goes on sale frequently and you can find year long codes for $40 or less if you keep your eye on CAG.
Gamepass hasn't really had many sales (outside the $1 month for Black Friday) and if there are digital codes you can buy for it I've never seen them (meaning no store sales either). So if you want gamepass that strikes me as the one least likely to go on sale significantly anywhere else. Cost wise $40 would get you what, 4 months of gamepass for same amount of points? Also, gamepass does a quest every month that gives away free things (typically for playing gamepass games) so that's something to keep in mind in terms of value.
I have an account just shy of 29k. I intend to use it on Gamepass for a year. My 2nd account is also getting up there, plan to use that for Xbox Live. I have a third account I only remember to do when really bored so maybe I'll cash in a couple thousand points for some freebie credit.
I know you have to spend the $5 within 90 days but how long can you wait to redeem the code?