It might have been their only chance at an education or they were dirt poor and this was the only career available that didn’t involve dealing drugs.
That's really a myth. Most of the military come from middle and upper middle classes, and those growing up in lower income households are underrepresented compared to the general population.