Apple doesn't have a spotless record with security. However, they are significantly better at pushing updates. A large majority of eligible iOS devices install OS updates, and iOS devices tend to be eligible for updates for many years.
Additionally, because sales are much lower for iOS than Android, it's hard to get to the same scale. I don't know about iPad numbers, but 1 billion iPhones is about 5 years of sales, and five years is around where Apple stops providing updates (edit: as pointed out below, they're doing closer to 8 years from release now, but not all sales are from current model phones) and that combines with other factors and very few devices make it past five years of use.
The iPhone 6 and SE are still hugely popular in Asia. I see them everywhere, and there is a whole after market economy for repairs and parts replacement.