Caveat: I'm in the USA, so what I'm about to say may only apply here. I don't know the market for software engineers outside the USA.
In 10 years, you and I will have 10 more years of experience than we do now. We will probably be twice as valuable to a company. Anyone who joins the field today will forever be behind us in years of experience. Years of experience means nothing if the experience isn't valuable, so we need to continue improving. That's a good thing.
I don't know the exact distribution, but not everyone who joins the field today will even be able to compete with us for jobs in 10 years. I'm just guessing here, but I think the majority of people, or at least a very large minority, don't make it to senior level. Some quit and change careers, others don't want to or can't get there.
I'm in no way concerned about job security in 10 years. I see AI being a larger threat to our jobs than other developers. But I doubt it will be a threat to my career. I have about 30 years left, and each year I have more experience than before. So AI would have to overtake me at some point in the next 30 years, and in the meantime also overtake /lots/ of others. The software engineering field would be fairly decimated by AI before it took my job.