The summer solstice is the longest day of the year because the Earth's tilt is greatest toward the Sun on that day. The axis of the Earth is tilted 23.5 degrees from the vertical as it follows its orbital path. This means that for part of the year, the Northern Hemisphere is tilted closer to the Sun, giving that half of the planet more daylight per revolution.
When one portion of the Earth is tilted towards the Sun, it receives more direct sunlight for longer each day. This increases the amount of heat transferred to the Earth and increases the amount of time each day that any given point on that hemisphere spends in sunlight. The effect is greater the farther away an observer is from the equator. Near the North Pole of the planet, the tilt is so pronounced that the Sun may not set at all during the days around the summer solstice.
Since one hemisphere is tilted toward the Sun while the other is tilted away, the Southern Hemisphere experiences the same phenomena six months later. June 21 is the shortest day of the year for countries such as Australia and New Zealand, whose summer solstice occurs on December 21.