Sun
The sun is quite clearly the most important factor that contributes to temperature. The fact that Earth is habitable is because of its distance from the sun. Planets that are farther from the sun are too cold for habitation and those that are closer to the sun are too hot. The transfer of heat from the sun is known as radiation. Earth's atmosphere locks out most of the harmful radiation, and it keeps in warm air at night.
Seasons
Seasons are a direct result of Earth's angle to the sun. The Northern Hemisphere is tilted away from the sun the most during winter, causing the cooler climate. Along the equator, however, the temperature stays the same because of the consistent distance of the equator relative to the sun. The sun's heat has a lot farther to travel to the North Pole and South Pole, which causes the temperature at these locations to be frigid.
Air Molecules
Air molecules are the second of the two most important factors in determining temperature because of their affect on air density. The molecules in air are made up of nitrogen, oxygen and other gasses. These molecules move at a very fast speed -- the faster they move, the more they push against their surroundings. This pushing causes the density of the air to increase and, in turn, increases the temperature of the air.
Density
To calculate density, divide air mass by the volume that it occupies. Lower air density is usually present in higher elevations, which is a contributing factor to lower temperatures in these regions. When moisture is added to the air, the density decreases and, in turn, the temperature decreases. The reason is that the air molecules don't have as much of an opportunity to move around due to a law in physics that dictates the total number of molecules in a cubic foot of air must stay the same.