The story of birth of Brahma Deva and how Varaha saved the earth from deluge is mentioned in Vishnu Purana’s second chapter.
At the end of the previous Kalpa, when Brahma awakened from his long slumber, he saw all the worlds devoid of everything. With a desire to save the earth from the depth of unfathomable inundation, He took the appearance of Varaha.
Entering the water, He reached Patala loka. Seeing Him, the earth prayed Him with respect. Hearing her prayers, the Lord roared with frightening sound. Then, He supported the earth on His great incisors and came out from the abysmal depth. When He was rising, His breath produced big sprays of water, which drenched sinless sages while the force of His breath frightened common creatures. When the Lord emerged from the water, all the sages prayed Him with reverence and respect.
Very soon, the Lord installed the earth at a position far above the unending stretches of water. Then, Lord carved out the topographical features on earth and divided it into many divisions and created all the four worlds. Then Lord Vishnu in the guise of Brahma carried out the process of creation.
As soon as Brahma thought of creation, Tamoguni (full of darkness) creatures were the first to appear. Absence of knowledge and presence of evils like attachment, anger etc. were the main virtues of these creatures. These creatures include lower organisms, trees, shrubs, creepers, plants and grasses. These together constitute the primitive world. Their creation was followed by the appearance of animals and birds, which are devoid of wisdom and are full of ego. They are also unaware of the nature of another organism of their status.
Still unsatisfied with His creation, Lord created the next world, which has a somewhat elevated position. The living beings that were produced in this world had internal and external knowledge, power of reflection and loved physical comforts. Though this creation pleased the Lord, He was still unsatisfied. So He created the next world, which was situated at a somewhat lower position. This new world had excess of all the three virtues. Human beings populate this world and because of excess of vices, they are full of sorrow but at the same time, highly active, have internal and external knowledge and are able to attain their goals.
The first few creations had resulted from the thoughts of the Lord. For the creation of the gods, the demons, Pitraganas, human beings and water, the Lord decided to use His body. Thus, the demons were the first to emerge from His thighs. The Lord then shed His dark body, which formed the night. Then from His mouth, the Lord produced the gods who had Sattvic virtues. The Lord then shed His Sattvic body as well from which the day came into being. It is also the reason why the gods acquire more strength in day and the demons are stronger during nights.
Then the Lord acquired yet another body and behaved like Pitraganas to produce Pitraganas before shedding that body too, which gave rise to the dusk- the twilight between the day and the night. Thereafter, the Lord acquired a new body with Rajas virtue from which the human beings were produced. When the Lord shed that Rajas body it formed dawn- the twilight between the night and the day. It also explains why the human beings are stronger at dawn and Pitraganas at dusk.
Then the Lord assumed yet another body with Rajas virtues and produced desire from it. The desire gave birth to lust. Staying in the darkness then, the Lord created the world, which is full of desire and lust. In that world, many ugly looking human beings, who had long beard and moustache appeared and ran towards Him. Among those who said, ‘Protect him’ came to be known as Rakshas (demons) and those who said, ‘We will eat him’ came to be known as Yakshas. Then the angry Lord produced aggressive carnivores. Thereafter, the singing Lord produced Gandharvas. Thus, by turns, the Lord produced birds, sheep, goat, cow, horse, elephant, donkey, deer, camel, pony from His age, chest, mouth, belly and feet respectively.
From the innumerable body hair of the Lord, fruits, flowers and herbs were produced. From His east-facing head, Lord produced Gayatri mantra, Rigveda, and Yagyas. From His south-facing head, He produced Yajurveda. From west-facing head, He produced Samaveda and from His north-facing head, He produced Atharvaveda.