Egg yolks are used to create a custard base, which gives the ice cream a richer, creamier texture and taste. They help emulsify the mixture and prevent ice crystals, resulting in a smoother final product.