In computer science and operations research, a genetic algorithm (GA) is a metaheuristic inspired by the process of natural selection that belongs to the larger class of evolutionary algorithms (EA). Genetic algorithms are commonly used to generate high-quality solutions to optimization and search problems by relying on biologically inspired operators such as mutation, crossover and selection.[1] Some examples of GA applications include optimizing decision trees for better performance, solving sudoku puzzles,[2]hyperparameter optimization, etc. It’s used in famous knapsack problem (given a knapsack/bag, and couple of items with various weight and value, the purpose is to fit the most items with the most value and least weight, and there is a weight limit for the bag) too.
Genetic representation of a solution needs a function to generate new solutions, fitness function, selection function, crossover function and mutation function.
The below diagram by Dr. Steven Brunton illustrate the algo clearly

For example, he needs to optimize a three-combination KpKiKd, each is made of three digit (0, 1) positions:

Encountering such a problem the instinct reaction would be applying Monte Carlo Simulation Search which will generate random rollouts and hopefully find out the path/solution quickly. but when problem dimension scales up, brute force, exhaustive approach – Monte Carlo is not feasible any more. Genetic Algo comes into play!
Genetic Algorithm introduces tournaments, then keep a good percentage of replication from elite/victory combinations, applies cross-over (exploiting) and mutation(exploring) functions to expand choices.