The midnight sun happens due to the manner in which the earth circles the sun in an elliptical orbit. The earth’s axis is tilted away from the sun for 6 months during winter, and towards the sun for 6 months during summer. This results in long seasons and Summer and Winter Solstice.
It occurs in locations north and south of the Arctic Circle. Reykjavik, in Iceland, is the northernmost capital on earth, therefore it experiences both the shortest (Winter Solstice) and longest (Summer Solstice) hours of daylight with the change of seasons.