The temple endowment ceremony is said to have been restored from ancient ritual:
It was through the Prophet Joseph Smith in the nineteenth century that the Lord restored again to earth the holy ordinances of temple covenants and blessings. ("Endowed with Covenants and Blessings," Ensign, Feb. 1995)
One has only to read the scriptures carefully, particularly the modern scriptures, to discover that temples must have been built and used in antiquity, even in the days of the antediluvian patriarchs. In Doctrine and Covenants 124:39, the Lord speaks of his holy house “… which my people are always commanded to build unto my holy name.” [D&C 124:39] (Italics added.) And why should not temples be as necessary for the giving of holy endowments to the living in the days of the ancient patriarchs as now? Surely the Lord’s requirements for the exaltation of men in antiquity would be essentially the same.
When one thinks of Enoch and his people who walked with God and were received into his bosom (Moses 7:69), it seems incredible that they should be so received without the endowments usually given to men in holy temples only. Much is said in Doctrine and Covenants 132:29–37 [D&C 132:29–37] about the blessings Abraham received as a result of his faith in God. The Lord says that he “hath entered into his exaltation and sitteth upon his throne.” (D&C 132:39.) The same may be said of Isaac and Jacob. (D&C 132:37.) Abraham, Isaac, and Jacob must have had sealed upon them all of the blessings of the gospel, including all of the holy endowments given to the faithful in mortality. ("Ancient Temples and Their Functions," Sidney Sperry, Ensign, Jan. 1972)
Joseph’s understanding of specific temple ordinances grew from these concepts in 1831 to a crescendo in 1844. In 1834, the need for a restoration of all the ordinances of the gospel was revealed: “We all admit that the Gospel has ordinances, and if so, had it not always ordinances, and were not its ordinances always the same?” ("The Restoration of Major Doctrines through Joseph Smith: Priesthood, the Word of God, and the Temple, Ensign, Feb. 1989)
Sacred ordinances and the divine authority to administer them did not begin with the Restoration of the gospel and the founding of the modern Church in 1830. The sacred ordinances of the gospel as requirements for salvation and exaltation were “instituted from before the foundation of the world.” 5 They have always been an immutable part of the gospel. The Prophet Joseph Smith taught: “Ordinances instituted in the heavens before the foundation of the world, in the priesthood, for the salvation of men, are not to be altered or changed. All must be saved on the same principles.” 6
If this were not the case, salvation would indeed be an arbitrary matter and would be restricted to those few who may have been fortunate enough to have heard of, and believed in, Jesus Christ. It is this principle of consistent and unalterable requirements that gives true meaning to the performance of vicarious ordinances in the temple. The Prophet wrote that baptism for the dead and the recording of such baptisms conform “to the ordinance and preparation that the Lord ordained and prepared before the foundation of the world, for the salvation of the dead who should die without a knowledge of the gospel.” 7
Through time and apostasy following Christ’s Resurrection and Ascension, however, the divine authority of the priesthood and the sacred ordinances were changed or lost, and the associated covenants were broken.(Dennis Neuenschwander, "Ordinances and Covenants," Ensign, Aug. 2001)
Of course, we know that Joseph Smith adapted the endowment from contemporary Masonic ritual and that Freemasonry has its origins in the Middle Ages, sometime around the 14th century. So, we still have folks like Nibley and others trying to find parallels to the temple endowment in antiquity.