To win is to be #1 in a competition, or to receive an award.
You can win a game, a race, a match, a competition, or the lottery. You can also win a medal (like in the Olympics), a prize, or an award.
To earn something is to get something in exchange for your work or effort, for example: a salary.
To gain something is simply to get or increase – not necessarily because of action: