I think it comes from the transport of goods of certain value across america in wagons, where a person would "ride shotgun" up front with the wagon driver to prevent bandits from stealing the goods.
The saying riding shotgun means that if you are in the passenger seat and there is an accident, That person will go flying thru the windsheild as though they were shot out of a gun.