Because Shanks is not a black and white villain (most likely). If he's modeled after Shimizu Jirocho, then he very likely is an altruistic person with decently good motives, but still does morally grey shit.
A lot comparisons can be drawn from him. You can ask
@ArturCantSpeakJapanese about this theory. He can still care about Luffy to an extent. But with secret motives, we don't know how deep they go.
yeah i think its less about betraying luffy himself and more about betraying luffy's image of him and pirates. i think shanks is someone who wants to control: events that can change history, the direction of the world, and ultimately luffy's goals. i think he knows more than he lets on and has plans for luffy to fill a specific role as a figure of prophecy and do something that shanks wants to see done.
and unfortunately for him luffy hates this kind of thing and will probably be really offended if he learns that shanks has been manipulating him and the world events to point him in these directions. even if in shanks' mind, he just wants the best for the world and for luffy, luffy might see this differently because he was ready to give up his whole journey at sabaody if ray told him spoilers. the idea of things not being a surprise, or being predetermined, thats something luffy really hates.
like, one example. luffy never actually found out shanks saved him at marineford. the specifics of the events that day in the very end were not broadcast publicly and almost nobody knows what really happened. jimbei was unconscious. luffy was also unconscious. the only people who luffy is associated with who actually know shanks saved him are buggy and trafalgar law, and theres a chance neither of them told him.
do you think luffy would be happy to learn shanks showed up to save him (and the hat) but couldnt show up five minutes sooner to save Ace? or would he be angry?
and in turn, i think shanks probably has no real emotional attachments here, and if luffy DOES argue back and hate this idea, shanks will just go well if youre fucking up my plans i have to teach you a lesson.