The term to ‘ride shotgun’ comes from the American Old West stagecoach custom of guarding a person or something of value. Someone typically rode on the buckboard together with the driver with a shotgun handy as a look out for robbers and bandits. It's not used much outside of America, but in the early 60's many movies portrayed this custom in American westerns.

It eventually became slang and riding shotgun is to ride in the front passenger seat of a car or truck. As in “Dibs on the front seat!” Dibs derives from a very old children's game called dibstones. This game, using with sheep knucklebones or pebbles, dates back at least to the 17th century. The purpose was to capture the adversary’s stones, and when a stone was captured, the winning player would call "Dibbs!" Meaning, "I claim (the stone)”. It soon came to be used outside the game but with a similar meaning, and there you have it.

Eventually the custom of riding shotgun developed a lively set of unspoken guidelines and if you're interested you might want to read more about them in shotgun rules.

This expression is still in vogue today, but is taking on a more sinister meaning.

My sons constantly call, Shotgun!!! when we get in the car.
I asked my youngest son, he was all of 8 years old, once what he thought the term shotgun meant.
Sadly he replied, "It's the seat the shooter rides in on drive-by shootings."

Out of the mouths of babes.

Many thanks to Mike1024 for pointing out the etymology of the phrase “riding shotgun”!

Sources:

The American Heritage® Dictionary of the English Language:
www.bartleby.com/61/80/R0238000.html -

Take Our Word For It :
www.takeourword.com/