War is certainly bad, really really and terrible. It should be avoided when ever possible, which is usually. Are there some rare cases where having a war is better than the alternative? Yes, when the alternative is really bad.
If another country invades yours, is it better to let them take over...