How do natural selection and adaptation explain behavior?
Natural selection and adaptation shapes behaviour as the other phenotypic traits. The most successful behaviours are more likely to reproduce and survive. An individual can also change its behaviour in certain limits depending the situation it faces.
Scientists measure the behavior of an individual using a scale going from shy to bold. Whether an individual is shy or bold will be determined by how it reacts to a novel object, if it stays more or less closer to a predator, how it behaves in an unknown environment, etc ...
The behavior has a genetic basis and can be transmitted by the parents. Like most of the other individual traits, it is also affected by the environment.
If we consider the foraging behavior for example, an individual faces a compromise: foraging more to acquire more energy, but being more likely predated or foraging less, acquiring less energy but being less likely predated. Bolder individuals will tend to take more risk than shy individuals and so, to forage more.
Consequently, in a population facing predation, shy individuals will be selected because they have a survival advantage. However, without predation, bold individuals are more likely to survive and reproduce because they have more energy to invest in growth and reproduction (acquired by foraging more).
In this case, natural selection by predation influences the general behavior within a population. It happens with other behaviors, such as agressivity, mating, ...