It's been a known issue for some time, that in certain conditions where SMF tries to write to the file multiple times in a row it can fail and wipe it clean.
As far as I know, it should be fixed for 2.1, somehow I thought that was the case for 2.0 as well though - but could be I'm mistaken.
This shouldn't happen often, and if it does then most likely you have an issue somewhere else with the server.
A workaround in that case would be to keep the settings.php file read only when you don't need to change it.