The credit card banks get a mercantile discount from stores-- it's around 2.5%. Stores know that the *average* shopper buys significantly more with plastic so it's worth the hit for them. Banks kick a portion of this back to the user, hoping to trap said user into paying fees or interest willingly or accidentally.
No bank does 5% on everything, all the time, so they do it for "conquest", to steal a customer from another bank then hope they get lazy and stick around with the card even when it drops the promo kickback to an actually profitable 1-2%.
I have a citi card and a chase card that offer 5% on rotating categories-- gas, food, utilities, travel. They top out at $300 a year in kickbacks so I have to track them and switch out when I near that mark. It's work keeping track of it all. There's a subreddit,
/r/churning for people looking for ideas. My NFCU Visa pays 1.75% on everything and is the default when I can't do better.