There are many words that mean the opposite of selfish, the most obvious ones being unselfish and selfless. To be unselfish/selfless means to care about others more than yourself. A more difficult word that means the same thing is altruistic. Meanwhile, generous means you like to give to or share with others, and compassionate means you show sympathy or concern for others.
To be selfish means that you act only in your best interest. If doing something does not benefit you, you will not do it.
The best antonym (opposite word) of selfish is selfless. When you are selfless, you act without thinking about yourself. Instead you are totally concerned with the needs of other people above your own, and you put aside your own ambitions to help someone else. This is often said of people who serve in public office and the military, or who donate to charity.
Other great words meaning the opposite of selfish are: altruistic, considerate, generous, magnanimous, benevolent, and philanthropic.