Physical activity > Physical inactivity
Martial arts can help with combating the ill effects of sedentarism, but martial arts aren't very special in that regard. Some instruction on proper posture is common, but exercises or practices to maximize it are not common. I'd recommend martial arts because it's a fun way to stay active while learning a skill, but not because it fixes posture. For that, I'd direct you to physical culture: lifting, physical therapy, specific exercises and practices (covered somewhat in these questions on Fitness.SE) to fix and prevent bad posture from sitting. Yoga would come before martial arts as a supplement for these things.
However, martial arts--again, like many physical activities--can greatly help with overall fitness and stamina. So would soccer, weightlifting, running, squash, and so on.
Define "Martial Arts"
Martial arts is also a broad category, spanning from hard-sparring arts like wrestling, kickboxing, and judo to non-combative dance practice like most American tai chi and vigorous but ritualized historical re-enactment like traditional Japanese jiu-jitsu. Whether something will help with or exacerbate your knee and shoulder pain depends on too many variables about you, your injuries, the style, and the school to say anything with confidence. You have to be more specific to determine anything of value.