Maybe it was stored at the port because it was about to be shipped? Why else do you think it was there?
And maybe there is a residential area because people tend to settle near ports? Have you looked at the blast? For it not to hit any residential area it would have to be built 10km outside of town but that's not really how city planning works.
There is probably plenty of blame to go around but please stay realistic here.
Edit: If it really has been left there for years that's certainly negligent.
Supposedly it was 6-7 years, its just been stored there.
They should have moved it, somewhere more remote, and safer, and away from a important area for their economy.
There is, you can find area's were even if it does explode, it doesnt wound or kill anyone.
Also it took out a entire port area, which they are dependent on, for their economy to work (which was already failing).
Its basically the worst handling of a such compounds you can imagine, next to it being placed in a houseing area with high density populations.
I guess it would be worse if it killed like 20,000 people or such. However from the positioning of those in power, the economical impact now, is probably worse for them than such a situation would have been.