Flavor. Preservation/shelf life. Oh, and it also happens to be what the brain screams for often. Both are needed for survival so its wired that way, of course it doesn't mean they both need to be coupled with additional saturated fats and excessive calories. Nothing wrong with salt and sugar otherwise.
Preservation or "shelf life" is in no way natural and the means to conserve food is not ideal for the body.
Sugar and salt is not flavor, really it is the opposite if you think about it twice.
If you eat a lot of salt and sugar you can't determine "real" taste anymore. A numbing of the taste buds. Have you tried going off and only eating very low sugar and salt diet you'd know this. I suggest you try.
"Nothing wrong with salt and sugar otherwise."
Sugar is at the core of unhealthy eating all across the world! Pure sugar is poison to your system, just because the brain screams for it like you would cocaine after continuous usage, does not mean it is good for you. That is a no brainer.