Health is the greatest gift, contentment is the greatest wealth, a trusted friend is the best relative, Nibbana is the greatest bliss. -
Dhammapada 204
For a lay person, moderate exercise, moderate diet and good hygiene can be considered as part of the middle way that the Buddha taught in the Dhammacakkappavattana Sutta, as it contributes towards the maintenance of one's health, which is beneficial to practice. You also cannot practise Right Livelihood without good health. The purpose of Buddhism is to escape suffering. And with poor health, you would only be causing suffering for yourself.
"There are these two extremes that are not to be indulged in by one
who has gone forth. Which two? That which is devoted to sensual
pleasure with reference to sensual objects: base, vulgar, common,
ignoble, unprofitable; and that which is devoted to self-affliction:
painful, ignoble, unprofitable. Avoiding both of these extremes, the
middle way realized by the Tathagata — producing vision, producing
knowledge — leads to calm, to direct knowledge, to self-awakening, to
Unbinding.
On the other hand, excessive exercise either for vanity or as an addiction (see here and here for the case of running addiction), are not considered skillful. In case you are afflicted with exercise addiction, the Buddha has a remedy in the Sukhamala Sutta:
"Even though I was endowed with such fortune, such total refinement,
the thought occurred to me: 'When an untaught, run-of-the-mill person,
himself subject to illness, not beyond illness, sees another who is
ill, he is horrified, humiliated, & disgusted, oblivious to himself
that he too is subject to illness, not beyond illness. And if I — who
am subject to illness, not beyond illness — were to be horrified,
humiliated, & disgusted on seeing another person who is ill, that
would not be fitting for me.' As I noticed this, the healthy person's
intoxication with health entirely dropped away.
In the case of monks, the Buddha explains in the Sukhamala Sutta:
"Drunk with the intoxication of youth, a monk leaves the training and
returns to the lower life. Drunk with the intoxication of health, a
monk leaves the training and returns to the lower life. Drunk with the
intoxication of life, a monk leaves the training and returns to the
lower life."
Despite this, I can still find some example of a monk trying to get light exercise, in the Meghiya Sutta (below). This leads me to think that light exercise without "intoxication of health" might still be considered acceptable to monks.
Then in the early morning, Ven. Meghiya adjusted his under robe and —
carrying his bowl & robes — went into Jantu Village for alms. Having
gone for alms in Jantu Village, after the meal, returning from his
alms round, he went to the bank of the Kimikālā River. As he was
walking up & down along the bank of the river to exercise his legs,
he saw a pleasing, charming mango grove. ...