Relative humidity is affected by temperature and the amount of moisture or water vapor in the surrounding atmosphere.
Hot or warm air can "dissolve" more water vapor than cold air. When warm air with a high water content is cooled the relative humidity increases. This is because the percentage ( relative humidity) of water vapor increases as the carrying capacity of the air decreases with no loss of water vapor.
Air over an ocean usually has a high water vapor content because of evaporation. This air, when it moves over the colder land mass will cool from contact with the ground. It will also cool if it rises in the atmosphere, as the atmosphere pressure drops as you go higher (simply because there is less atmosphere above you). The Gay Lussac law states pressure and temperature are proportionate (as one drops so does the other). The cooler air has less ability to hold water vapor in solution. If the air cools enough the amount of vapor in the air will reach the point where it is the same as the maximum amount of vapor the air can hold. This will result in the water vapor condensing, resulting in cloud formation.
If the temperature of the air remains the same the relative humidity can be affected by adding water vapor. If a sample of air is holding half of the total amount of water vapor it can hold, and we add more water vapor, the relative humidity will start at 50% and then increase.
The vertical on this chart is the actual mass of the water in the air (called absolute humidity or mixing ratio). The horizontal is the air temperature. The red curve indicates at what temperature the absolute humidity is at the maximum (100 percent relative humidity). You can see that if you start with a given absolute humidity (say 20g/kg of air), at 35 Celsius it is holding about half the vapor it can. If that air cools to 25 Celsius, it is now at 100 % relative humidity.