The purpose of almond flour in a cake is to provide a gluten-free alternative to traditional wheat flour, imparting a nutty flavor and contributing to a moist and tender texture.