Why is it that Allah swt took six days to create the earth when he could say kun faaya kun and immediately the earth could have been created?

Indeed he is capable of creating it within a twinkle of an eye. he did so in six days to show us that things are achieved through step by step process and not over night