Where did the minhag of wearing a gartel come from?
Shulchan Aruch (Orach Chaim 91:2) states: "One must wear a gartel (Heb. ezor) while praying, even if he has a belt (to hold his pants up - Mishnah Berurah sec. 5) so that his heart doesn't see his private parts; this is in order [to fulfill the dictum], 'Prepare [yourself to meet your G-d, O Israel]' (Amos 4:12)."
Mishnah Berurah (sec. 4) qualifies this ruling as applying only to someone who regularly wears a gartel throughout the day, though he concludes that it's a mark of piety ("middas chassidus") to put one on for prayer regardless.
There is a machlokes in Tosefos Shabbos 9b whether one one wears a gartel to avoid libo roeh es hoerva (his heart seing his ervah) or for hikon likras E-lokecho Yisroe-l (Prepare to greet Hashem, O Israel).
The simple explanation is like the second opinion.
A Gartel is an expression of seriousness toward prayer in that it is a major time of spiritual growth.
In Chabad, bochurim (unmarried men) wear a gartel under their clothes so that their Gartel should not attract attention. In addition to that, a married man wears a gartel when praying, similar to a warrior preparing for battle by girding himself, we too, in our battle against the Yetzer Hora (evil inclination) should gird ourselves.
This is consistent with the Zohar that calls the time of prayer a time of battle-"SHAAS TZELOSA SHAAS KEROVA"