Numbers 8:17
For all the firstborn of the children of Israel are mine, both man and beast: on the day that I smote every firstborn in the land of Egypt I sanctified them for myself. For all the firstborn of the children of Israel are mine, both man and beast: on the day that I smote every firstborn in the land of Egypt I sanctified them for myself.
All of Israel's firstborn, both people and animals, belong to God because He set them apart for Himself on the day He struck every firstborn in the land of Egypt. To sanctify in this sense is to set apart as His own for His service and glory. It is the same sense in which the seventh day was set apart as His own from creation.
The Levites were taken by God in place of Israel's firstborn. This appointment belongs to the Mosaic instructions for appointing the Levites to their service. The returned Jews followed those instructions as the pattern when they arranged the priests and Levites for temple worship.