Billions of pounds is being invested into modernising more than 40,000 military family homes as part of a decade-long overhaul.