"Gain" is when you acquire something as an increase or addition. So for example, during the holidays I usually gain weight.
Could you say gain more money? No. You earn more money.
"Earn" means to obtain or get something in return for one's personal efforts. Example: So if I work harder I might earn more money. If I try to be kind to people I might earn their friendship.