You are underweight you should gain weight, but gaining weight doesn’t need to be a bad thing. If someone that say weighed 120 but never worked out and ate unhealthy would look unfit and chubby compared to someone with the same weight but worked out and ate healthy. So try gaining weight but also try to get tone in the process. If you have bad knees try swimming and there will be no pressure for them. most exercises for hips and thighs would probably be too aggravating for your knees.