At different times of the night the Messenger of Allah ﷺ prayed Witr at the beginning, in the middle and at the end. Then he settled on praying Witr at the end of the night.
مِنْ كُلِّ اللَّيْلِ قَدْ أَوْتَرَ رَسُولُ اللهِ ﷺ مِنْ أَوَّلِهِ وَأَوْسَطِهِ وَآخِرِهِ فَثَبَتَ الْوَتْرُ آخِرَ اللَّيْلِ