You do realize military personnel don't just carry 80-pound packs and shoot guns all day right? They do spend some time training for things like that, but they also have mechanics, truck drivers, journalists, support staff (office staff), pilots, engineers etc. Think of each individual Army installation as it's own country. Each one has virtually all the parts it would need to function as a country. Until recently when a good portion of the service side of things were privatized to "save money".
So someone entering the Army with only a high school as a mechanic starts at an E1 while in training. That's about $17,000/year after boot camp plus housing and other smaller allowances for uniforms etc. Well the Army is going to pay that E1 his base pay, put a roof over his head, provide full benefits etc. while training him to be a mechanic. His friend that didn't join up but still wants to be a mechanic might make a little more as an apprentice but won't get tax free housing, will probably have to pay some part of the benefits premiums if they're even offered and will also have to pay for school.
Also, that E1 will get to retire with his full benefits and 80 percent of his ending base pay when he's 38. Coincidentally, that's a much, much bigger attraction than base pay is the early retirement offered through the Army. At 38 he's free to either stay in or "retire" go find another job in the private sector or, what usually happens, be hired by a military contractor to do the same job at the same post for more money.
This isn't even taking into account the fact that at some point this soldier might get married and qualify for off-post housing, receiving a nice monthly check that can easily pay a mortgage and all utilities and then keep everything when his time is up. FWIW, a E1-E4 soldiers at Fort Riley receive between $950-$1400/ month for housing allowances if they live off post. That's tax free and in addition to their base pay. Fort Riley is also on the bottom rung of installations for allowances. On the coasts, those allowances can start at $2,000-plus. And that's the lowest level enlisted soldiers. No sergeants, SFCs or officers.