Some reactions turn out to be exothermic or endothermic. But why does this occur? Why do some reactions need energy to bond but some release energy to bond?
A chemical reaction occurs from reactants to products, which are both characterized by their energies. If you go from reactants to more stable products, the reaction may be exothermic by releasing the energy difference between the two species. This is a simple example but some systems could be a lot more complex.
A way to predict such a behaviour would be using computational chemistry to compute the energies of the reactants and the products.
It's also possible to play on some effects such as the solvent to stabilize (higher energy) or destabilize (lower energy) the system. Thus, it could make the reaction more exothermic in a specific solvent than in another one for instance.
Chemical bonding is just an electrostatic. But what happens is that we get so many charges I.e. electrons and nuclei that it everything becomes very complicated.
If the reactant is more stable than product ( I must clarify stability is just about electric potential energy, but due to so many other charges with complicated arrangements it’s not possible to say who is more stable just by looking) than we have to apply some energy to break the bonds of reactants and when new bonds will form it’s not gonna release much energy so as to nullify my given energy and hence the net energy will be transferred to the system and we will an endothermic reaction.
On the other hand if product is more stable so sometimes (spontaneous reaction) reactants will react by themselves and hence potential energy gonna drop so we will get energy out of this reaction. Even if I have to apply some energy to make the reaction go then also product would release energy due to drop in potential energy and this release of energy would be more than what I applied for the reaction to occur and hence we will get an endothermic reaction.
Chemistry is a very experimental subject, we can find about endothermic or exothermic reactions only by experiments. But if we know few data we certainly can make predictions whenever those reactions gonna occur. For example an acid base reaction is always exothermic so whenever there is a reaction between any whatsoever base and an acid we can say theoretically that it is exothermic.
Hope it helps