The first of the good habits is a good diet. The first medicine is food.
You can have a mediocre diet and still see huge health benefits. The opposite is not true: a sedentary lifestyle will kill you and the last years will be miserable with little in the way of physical autonomy.