Gems are earned by completing Achievements and through Daily Rewards. You can also purchase gems in exchange for real money from the game’s Premium Store. To access the Premium Store, you tap on the plus (+) sign next to the gem total displayed at the upper right-hand corner of the game screen.
Gems can be used to purchase some items in the Shops and to speed up timers. It can also be used to upgrade parts of a building even when the needed resources haven’t been collected.