the answer is that some amount of intense physical activity outside of work is required. weight lifting is probably the most efficient. having more muscle than you strictly need helps with sitting for long periods because they help hold your body and take stress off your joints and ligaments, which are the things that hurt when you sit for too long. it also helps strengthen your tendons and ligaments and other connective tissue so even if you do stress them they can take it better. every time ive had pain or stiffness from work its been because i was skipping physical activity, and the least pain was when i was keeping a good lifting routine. these days i climb and ride my bike to work and that seems to be working really well but i do plan to start lifting again soon.
beyond that having even a mediocre diet goes a long way. living mostly on junk food and caffeine is going to make things worse even if you are getting enough physical activity outside of work.