An animal eating gets energy to spend (oxidases food). It spends in actions which ultimately leads in reproducing a mutated animal (it couples the free energy released by the oxidation to order processes that instead requires free energy). The new animal is a muted version in a resource limited environment, and all animals use the same resource. Therefore the bests survive on avarage.
This does not violates the first thermodynamic law: the animal gets energy from the apple, energy is not credited nor destroyed.
Also the second law is not violated: the processes that you can couple to your eating (leading to reproduction) require less free energy than you get from the apple. If you count the system apple plus you than the entropy always increases.