Question: what is the most important thing to gain weight?
Answer: The most important lifestyle factors allowing you to gain weight and muscle are sufficient exercise and proper nutrition. Specifically, you need to eat more calories than your body uses and eat more protein than your body breaks down.