Cubes are essentially the lives of Dancing Line. When you first play the game, it gives you 20/15 Cubes. When you go under 15, a timer will appear. After every 2 minutes, you get a Cube. You can also watch an ad to get 15 Cubes.
A variant of the Cubes are Hearts, which were added in The Savanna update, and are needed to restart at checkpoints. This is, arguably, one of the most controversial elements in Dancing Line, because it replaced the old way of reviving; paying with Gems or watching ads. After The Faded update, if you pay to remove ads, Hearts will be removed too; you will be able to play the game without ever needing Hearts again.