Sometime after the Battle of Jakku, Jedi Master Luke Skywalker discovered or built this Jedi Temple on an unknown planet, to serve as a Jedi academy; in order to train a new generation of Jedi Knights and establish a New Jedi Order, realising that the old Jedi teachings as well as the old code were flawed and to avoid the New Jedi Order from making the same mistakes as the Old Jedi Order - Luke altered some of the Jedi teachings and code.
The First of Luke's students was his nephew Ben Solo and several other Force-users. Unfortunately, his nephew fell to the Dark side partly due to the manipulations of the mysterious Supreme Leader Snoke. As Snoke preyed on Ben's internal conflict, when he discovered his uncle Luke wanted to kill him, because he was afraid of how stronger connection to the Dark side of the Force was. Ben then killed most of Luke's apprentices and the rest of his fellow Jedi joined him.
Luke was in horror as he was unable to stop the Jedi massacre, Luke and his astromech droid R2-D2 watch as most of the Jedi Temple was burning, Luke when in search of Ahch-To Jedi Temple, as he was guilt ridden over Ben's fall to the dark side and the death of most of the students. Luke would remain in hiding on Ahch-To, until the time would come when he dies; the Jedi Order ends with him.