The fitness function has the ability to measures how good your solution is. In particular, it should be able to handle whatever the available solutions generated and have to show the right way to improve them.
For example, a fitness function that is zero unless the answer is right is not good, because it doesn’t help you get an idea of how close the solution is to the right answer. Also, a fitness function that increases as solutions get better, but doesn’t identify the best solution is not so good either, because your population will improve up to a certain point and then get stuck.
For further knowledge about How you can define a Fitness Function in a Genetic Algorithm, refer the following link:
If you wish to know more about the Genetic Programming and Genetic Algorithm then visit this Artificial Intelligence Course.