The main reason is the tilt of the earth. The time of the year has something to do with it as the rays of the sun strike the earth more directly in the northern hemisphere in June, July and August giving the northern hemisphere warmer weather and less directly in December January and February giving us colder weather.
In the southern hemisphere the situation is reversed.