Shanks is a very patient and wise character in the series, and he has many reasons for refraining from fighting back.
First of all, he has a strong conviction that he will never go back on a promise he makes. He promises not to get involved with the war between Whitebeard and the Marines, and holds true to that promise. He is willing to risk his life to keep his word, so he keeps his distance and will not get involved in any fights.
Secondly, Shanks knows that Luffy is watching and is looking up to him. He is aware that his behavior will be a major influence on Luffy, so he tries to act as a responsible role model. Even though Shanks could easily take out any opponent he has, he deliberately refrains from fighting as to not encourage destructive behavior in Luffy's young heart.
Finally, Shanks is aware that he has yet to prove himself as a powerful pirate and doesn't spend his time fighting unimportant battles. He is focused on waiting for the moment to show his strength and might. So by not getting involved in petty fights, he keeps his strength and power up to prove himself and impress Luffy.
To sum up, Shanks knows his limitations and is aware of the influence of his actions. Though he could easily win in any fight, he calmly constrains himself, stepping aside and remaining the reliable role model for Luffy.