Good question, I am no scholar but know the answer to the question. Well to begin with see it as levels of infallibility. With the infallibility of our fourteen masooms it is to an extent that they are all pure not even an atom of bad deed or even the thought of it. In terms of transgressions against God we have something termed as terq e ola. I personally cannot define this term but only remember an example of it. I am sure you know of the story of Prophet Nooh when he was asked to find Gods worst creation and chose a black dirty dog? Well this was a terq e ola and because of the possibility of committing such by 123999 of our Prophets they are not infallibles at the level of the chosen fourteen.
Also another point bearing in mind when asking about purity of Prophets and selected other individuals is that the Ehle Kisa were created from the very light of God himself. Before any of Gods creations, this world this universe and other universes there was only the noor of Allah and from that noor came the Ehle Kisa. So their purity is of the highest calibre. Imam Ali
has stated that he was present when the clay model of Adam
was being made. Well I hope this helps in answering your question.
How does he, whose guardian is Allah, get perished? And how can he, who is being pursued by Allah, get salvation? (Imam Mohammad Taqi
)