The very short "how this helps security" for a lot of the pain, including this particular pain point, is pretty simple. Javascript comes from servers that the end-user doesn't control and shouldn't trust. Malicious developers (including advertisers and people trying to make bot nets) have taken advantage of the loose controls that browsers implement to put files on your computer without you even needing to do anything other than go to a website that happens to have an ad on it. The ad loads some javascript, the javascript puts files on your computer and runs them. Bam, you have a virus or worm or trojan or ransomware or spyware etc. You didn't have to do anything. It's called a drive-by download.
The other way around also works in that the javascript can look at files on your computer and tell your computer to send them somewhere, thus stealing information from you without you even knowing.
If the browser lets the website (javascript) set the path and name of a file and allows overwrite of existing files, then the javascript can replace proper normal programs with their trojans etc.
This, and may other attack scenarios keep coming back, even after the developers think they've fixed the problem. It isn't that the developers don't know how to fix the problem, they do. But the fix is to fix the underlying design flaws in the browser and significantly restrict what all that code from websites can actually do on the end-user's computer.