These guys guard the north, south, east, and west entrances to the Temple. Don't let in any impure people or God will be very, very angry.
Naturally, they also cast lots to see who gets what guard duty.
David also gets a group of men to be in charge of the Temple treasury. These are the money men. Any time someone gave a gift to the Temple these guys were all over it.
The king also needs assistants, so David makes sure that some men will be left over to serve as his officers, judges, and councilors.
That means the Levites had both religious and secular stuff to take care of. The Temple couldn't run smoothly without them.