As David allocated tasks for the new Temple, he found himself with a few more Levites than Moses had when he divvied up the work on the tent of meeting (the Tabernacle) in the wilderness.
He chose to allocate the work by lot:
1 Chronicles 24:5 All tasks were assigned to the various groups by means of sacred lots so that no preference would be shown, for there were many qualified officials serving God in the sanctuary from among the descendants.
He also used this method for picking family leaders from the Levites, and for picking musicians from three very talented Levite families:
1 Chronicles 25:7-8They and their families were all trained in making music before the Lord, and each of them—288 in all—was an accomplished musician. The musicians were appointed to their term of service by means of sacred lots, without regard to whether they were young or old, teacher or student.
David was very old by the time he did this. It is one way of avoiding bickering over who has the king’s favour, and of making sure arrangements lasted past the king’s death. After all, the lots show that God chose who did what, not the king!