Chemicals react because it is energetically favorable for them to react. Just like rocks fall because it is energetically favorable for them to fall. The specifics of which chemicals will react under what conditions to form which products will be a major part of your study of chemistry, but in the end it all comes down to energy. Rocks have a certain amount of energy, called potential energy, bound up in their position, which can be released when they fall, and increased if energy is added to lift them higher; chemicals have energy bound up in them based on their arrangement of bonds and other interactions, which can be released by rearranging those bonds into more stable configurations, or increased by adding energy and forming less stable configurations.