(Ali-Imran) 3 : 44
ذَٰلِكَ مِنْ أَنْبَاءِ الْغَيْبِ نُوحِيهِ إِلَيْكَ ۚ وَمَا كُنْتَ لَدَيْهِمْ إِذْ يُلْقُونَ أَقْلَامَهُمْ أَيُّهُمْ يَكْفُلُ مَرْيَمَ وَمَا كُنْتَ لَدَيْهِمْ إِذْ يَخْتَصِمُونَ

Those are from the Unseen Divine Information We are revealing into you, and you were not there with them when they drew lots with arrows to decide who among them will guard Maryam, and you were not there with them while they were disputing.

Since it was for the first time a female was appointed for Lord’s service, there aroused a dispute among them for taking the guardianship of Maryam. Thus, they drew a lot and Zakaria got the chance for it. It is told in verse 12: 102: “Those are from the Unseen ‘Devine Information’ We are revealing unto you, and you were not there with them while they gathered for plotting”. It is told in verse 7: 101 after explaining the history of Prophets Noah, Hood, Swalih, Shuhaib, Looth, etc., the Lord says: “Those were the towns whose histories are explained to you one by one; surely, their Messengers had come to them with Explanations, but they persisted in their disbelief, thus, the Lord is sealing up the hearts of disbelievers”. See explanation 2: 252; 12: 3 and 111.