The word 'gym' comes from the Ancient Greek 'gymnadsomai' which means 'I train myself naked'. Ancient Greece is my thing, so I'll focus on that.
It was by no means the same phenomenon as modern day 'working out', where there is an abstract goal of being fit or looking better. In fact, the classical statues that we admire now were, in the Greek mind, always known as divine and unattainable.
It was a more socio-cultural thing, which one might argue the modern gym experience is becoming more and more. The ancient people who trained were the core of the military, the free citizens who could afford armour (the hoplites), there was no standing military. So, the knock on effect of gymnasia was having a more fit, organised and tight knit citizen body; but it was never an institutionalised regime of training. Unless you where in Sparta, where it was exactly that.
You're right about the wealthy not working too much (at anything, not just athletics), which implies you need to practice at something to earn your living.
Sorry, we don't allow throughout history questions. These tend to produce threads which are collections of trivia, not the in-depth discussions about a particular topic we're looking for. If you have a specific question about a historical event or period or person, please feel free to re-compose your question and submit it again. Alternatively, questions of this type can be directed to more appropriate subreddits, such as /r/history or /r/askhistory.
In Ancient Roman baths, the baths were large, cheap, and public. In addition to the rooms for bathing, there was often a Palaestra which is an area used for exercise, and often for wrestling, which comes from the Greek tradition.