The original meaning was literally "on horseback" — referring to mounted soldiers ready for action. Over centuries, this military readiness evolved into the everyday meaning of "immediately."
usage
马上 often pairs with 就 for emphasis: 马上就来 (coming right away). In practice, Chinese 马上 can be quite elastic — "马上" from a friend might mean anywhere from 1 minute to 30 minutes.
grammar
马上 goes before the verb: 马上走 (leave immediately), 马上吃 (eat right now). It can also be used with 要 or 就要 to indicate something is about to happen: 马上要下雨了 (it's about to rain).