A recent comment from reddit:

This year I became a co-owner of the company that worked at for the past three years. It's a small development and consulting company and we're currently struggling to find new developers. At the same time, my girlfriend is trying to get her foot into this field. Since she's interested in a completely different tech stack than what we use, hiring her through good ol' nepotism is not going to happen. This situation gives me a small glimpse into both sides of the whole equation.

Before I continue, I want to point out that no side is at fault here. It's just market forces at play.

So why don't companies want to hire newcomers? It's simple, really. It's never worth it.

Even newcomers want competitive salaries because bootcamps, popular media, etc. paint the picture of a career in software-development as being extremely well-paid and with great benefits. This picture is absolutely true -- for senior developers.
Meanwhile newcomers need to be trained and built-up, often with intensive mentoring from senior staff. In general, there's nothing wrong with that. I had a great mentor and in turn I love mentoring. But once they've gained know-how and experience, they will look for a different company hoping to use their newly acquired commercial experience as leverage to get better compensation. And that's exactly what they should do! Trust no employer that talks about crap like loyalty.
Leaving your first job after max 2 years is something I would recommend every new developer. It is what the legendary Andrew Hunt (author of The Pragmatic Programmer) recommends in this podcast episode. If your first employer gives you a hefty competitive raise to keep you, use it as the new base for negotiations and still try to switch because, as Hunt puts it, at the beginning of your career it's crucial for you to expose yourself to different technologies. Maybe you'll start out as a web developer only to find out after your first job switch that you're much happier in embedded systems. Switch jobs often. Forget loyalty.

But what does that mean for employers? Let me explain it with a few of our cases. In the past, we tried hiring newcomers multiple times. In the most recent case, I was the senior responsible for the new hire. I spent up to 16 hours per week on one-on-one training in the first 6 months to get them up to speed in anticipation of a big project. They left us after 14 months for a different job in the middle of said project. I do not blame them, it's the exact right thing to do. For us, this was our third failed attempt of hiring newcomers and it was frustrating and extremely costly.

Since we're a B2B company creating software for IT departments, I asked around to see how our clients approach this whole situation. And the consensus is, "We refuse to train the future employees of our competitors. Hiring newcomers is a waste of resources. Paying the premium to get senior developers is always better."
Especially small IT and software departments/businesses cannot afford training people who will just ditch the place within 2 years while big players like the FAANG companies can and have their pick from the very best newcomers.

As a result, entering this field is incredibly difficult and one has to essentially hope a company is dumb or desperate enough to take the gamble of hiring someone trying to get into developing.

So how can this be fixed? Well, I don't think there's a fix. Most newcomers will never find a job and quit trying to enter this field, the lack of senior developers is going to hurt small and mid-sized companies in the long run and many of them will eventually disappear from the market as their current developers are reaching retirement and cannot be replenished. Only newcomers who give the impression that they don't need extensive training will ever have a chance to get hired. As such, my recommendation is portfolio is king.