A lot of the time if you're underweight, eating without exercise wont help you gain any weight. And you have to make sure you're eating the good stuff, not the crap. Don't eat crap food, eat healthy. Proteins and good fats.
You need a balance in your diet, therefore when you exercise and eat right, your body will stabilize. Exercise isn't just for people who want to lose weight, but also for people who want to gain it.
I'm 5'7" and 113 lbs. Which is essentially 10 lbs underweight. My metabolism works really fast, so if I'm not utilizing that protein and carbs, where do you think it goes? You guessed it.