Proceed through the Desert Ruins Zone 2 area until you pass the last checkpoint ahead of the area boss. You'll find a beehive with three holes. Select the lower one and you'll obtain four lives. Then you can kill Sonic and resume play from the checkpoint. It's easy to then collect four more lives, then die and repeat the process as desired, earning three additional lives each time.