It's even more fundamental than that. The world is built on C and C++, both of which were designed a long time ago and without safety and security in mind.
That's true, but it is actually possible to write C and C++ safely, it's just really difficult and really expensive and requires a lot of discipline, so it's not very fun.
So crappy code is cheaper to develop in the first place, and then companies can sell more down the line when new versions have bug fixes and security improvements. There's really no incentive to change anything.