The egg prevents the ricotta from drying out. It makes the filling extra creamy when it's baked.