There is a lesson to learn

Behind all destructions, whether the immense destructions of Nature, earthquakes, volcanic eruptions, cyclones, floods, etc., or the violent human destructions, wars, revolutions, revolts, I find the power of Kali, who is working in the earth-atmosphere to hasten the progress of transformation.
All that is not only divine in essence but also divine in realization is by its very nature above these destructions and cannot be touched by them. Thus the extent of the disaster gives the measure of the imperfection.
The true way of preventing the repetition of these destructions is to learn their lesson and make the necessary progress.
[CWM2, 15:17]
Someone has said that disasters and catastrophes in Nature, earthquake and deluge and the sinking of continents, are the consequence of a discordant and sinful humanity and with the progress and development of the human race a corresponding change will come about in physical Nature. How far is this true? 
Perhaps the truth is rather that it is one and the same movement of consciousness that expresses itself in a Nature ridden with calamities and catastrophes and in a disharmonious humanity. The two things are not cause and effect, but stand on the same level. Above them there is a consciousness which is seeking for manifestation and embodiment upon earth, and in its descent towards matter it meets everywhere the same resistance, in man and in physical Nature. All the disorder and disharmony that we see upon earth is the result of this resistance. Calamity and catastrophe, conflict and violence, obscurity and ignorance—all ills come from the same source. Man is not the cause of external Nature, nor external Nature the cause of man, but both depend on the same one thing that is behind them and greater, and both are part of a perpetual and progressive movement of the material world to express it.
[CWM2, 3:38]
The resistances of the inertia that is in every consciousness and in Matter mean that this Action, instead of being direct and perfectly harmonious, becomes confused, full of contradictions, clashes and conflicts; instead of everything resolving itself “normally”, so to say, smoothly—as it should be—all this inertia that resists and opposes, gives it a tangled movement in which things collide and there is disorder and destruction, which become necessary only because of the resistance, but which were not indispensable, which might not have existed—which truly speaking should not have been—because this Will, this Power is a Power of perfect harmony where each thing is in its place, and it organises things wonderfully. It comes as an absolutely luminous and perfect organisation, which one can see when one has the vision; but when it comes down and presses on Matter, everything begins to seethe and resist. Therefore, to attempt to impute the disorders and confusions and destructions to the divine Action, to the divine Power, is another human foolishness.  It is the inertia—not to mention the bad will—which causes the catastrophe. It is not that the catastrophe was intended, nor even foreseen, it is caused by the resistance.
[CWM2, 10:231]
The upsetting is always caused by a resistance. If there were no resistance there would be no upsetting. So it can be a resistance which is the cause of cataclysms, earthquakes and cyclones, tidal waves, engulfment of continents, volcanic eruptions, etc.
[CWM2, 7:17]
Why should earthquakes occur by some wrong movement of man? When man was not there, did not earthquakes occur? If he were blotted out by poison gas or otherwise, would they cease? Earthquakes are a perturbation in Nature due to some pressure of forces; frequency of earthquakes may coincide with a violence of upheavals in human life but the upheavals of earth and human life are both results of a general clash or pressure of forces, one is not the cause of the other.
[SABCL, 22:492-93]

What should be our attitude in the face of such calamities?  Can our attitude have an effect or change the circumstances themselves?  It is said that the best always happens.  What does it mean exactly?

Is it really the best that always happens?… It is clear that all that has happened had to happen: it could not be otherwise— by the universal determinism it had to happen. But we can say so only after it has happened, not before. For the problem of the very best that can happen is an individual problem, whether the individual be a nation or a single human being; and all depends upon the personal attitude. If, in the presence of circumstances that are about to take place, you can take the highest attitude possible—that is, if you put your consciousness in contact with the highest consciousness within reach, you can be absolutely sure that in that case it is the best that can happen to you. But as soon as you fall from this consciousness into a lower state, then it is evidently not the best that can happen, for the simple reason that you are not in your very best consciousness. I even go so far as to affirm that in the zone of immediate influence of each one, the right attitude not only has the power to turn every circumstance to advantage but can change the very circumstance itself. For instance, when a man comes to kill you, if you remain in the ordinary consciousness and get frightened out of your wits, he will most probably succeed in doing what he came for; if you rise a little higher and though full of fear call for the divine help, he may just miss you, doing you a slight injury; if, however, you have the right attitude and the full consciousness of the divine presence everywhere around you, he will not be able to lift even a finger against you.
I have had innumerable examples of the power of right attitude. I have seen crowds saved from catastrophes by one single person keeping the right attitude. But it must be an attitude that does not remain somewhere very high and leaves the body to its usual reactions. If you remain high up like that, saying, “Let God’s will be done”, you may get killed all the same. For your body may be quite undivine, shivering with fear: the thing is to hold the true consciousness in the body itself and not have the least fear and be full of the divine peace. Then indeed there is no danger. Not only can attacks of men be warded off, but beasts also and even the elements can be affected.  I can give you a little example. You remember the night of the great cyclone, when there was a tremendous noise and splash of rain all about the place. I thought I would go to Sri Aurobindo’s room and help him shut the windows. I just opened his door and found him sitting quietly at his desk, writing. There was such a solid peace in the room that nobody would have dreamed that a cyclone was raging outside. All the windows were wide open, not a drop of rain was coming inside.
[CWM2, 3:154-55]