There are multiple ways to gain Gold. The Residence building will generate a certain amount of gold over time. Like other resource buildings, the Residence can be upgraded to increase the rate of production and how much it can store before stopping.
You can also earn Gold by recovering a village from the Blackguard's evil enslavement bases. There is a reward when first freeing the village, and while the village is free it will build up in a resource boat that will be sent every thirty minutes.
Wood is the first and main resource used to upgrade buildings. It is generated by the Sawmill that you have on your base at all times. You can also gain wood from freeing a Village, but unlike Gold, freed villages do not generate Wood for you to collect.
However, there are resource bases that were captured by the Blackguard, and you can recover it by destroying the outpost. While recovered, Wood resource bases generate Wood like a freed village generates Gold, except on a different boat.
A third way to earn Wood is by the free Daily Reward earned at 12:00 AM server time, and the fourth way is by gaining it from a Submarine mission.
Diamonds are the premium resource in Boom Beach, and you start out with 50 Diamonds. Diamonds can be used to "warp time" (by instantly completing an upgrade that is blocking you from upgrading something else, or instantly collecting the required resources for an action that require it).
Like most free-to-play games (sometimes called free-to-pay games, including Clash of Clans), you can gain Diamonds slowly, in this game it is earned by clicking the chests on the map.
Unlike Clash of Clans, you cannot just purchase resources using Diamonds from the Diamonds menu, you must do an action that requires resources and click the Diamonds button to use Diamonds to get the required resources.
Stone is another verson of Wood introduced in Headquarters level five, and must be used as well as Wood in upgrades introduced after Headquarters level five. It is earned in the same ways as Wood, but the building that generates Stone is the Quarry (unlocked at Headquarters level six), and you must recover Stone resource bases to gain Stone from a Stone resource boat. You can also use Diamonds to obtain the required amount of Stone to upgrade a building.
Iron is a third verson of Wood that is introduced in Headquarters level nine, and must be used as well as Wood and Stone in upgrades introduced after Headquarters level nine. It is earned in the same ways as Wood, but the building that generates Iron is the Iron Mine (unlocked at Headquarters level ten), and you must recover Iron resource bases to gain Iron from an Iron resource boat. You can also use Diamonds to obtain the required amount of Iron to upgrade a building.