He wants to indicate the necessity to be prepared in time for His second coming from heaven.
The church is also referred to as ‘the bride of Christ’.
Jesus, the heavenly Bridegroom, ascends to heaven after being resurrected from the dead, to ‘prepare a place’ for His bride.
But He will come back for her, and take her to the heavenly wedding feast.
In this parable all ten virgins have been invited to the wedding feast.
In those times it was common for the bridesmaids - girlfriends of the bride - to go from the parental home of the bride to meet the bridegroom when he came for his bride. In the parable five girls do not take oil with them for their lamps (torches).
They are called ‘foolish’. The five girls, who do take oil with them, are ‘wise’.
It is true that the five foolish girls got an invitation to join the wedding feast. They had a lamp too. But in the middle of the night, when the bridegroom appears, it transpires they are not prepared for his coming.
The wise girls cannot share their oil with them and advise them to go and buy oil. They do, but eventually they’re too late. The door of the wedding hall is already shut. They call: "Lord, Lord, open to us!"
In Jewish idiom the repetition of the name or title indicates a personal bond with the one addressed.
It is plausible that the bridegroom knew the persons who received an invitation, yet he answers; "I do not know you", which can be explained as: "I don’t want anything to do with you".
This reminds us of Matthew 7 verse 21 to 23:
‘Not everyone who says to Me, ‘Lord, Lord,’ will enter the kingdom of heaven, but the one who does the will of My Father who is in heaven. On that day many will say to me: ‘Lord, Lord, did we not prophesy in Your name, and cast out demons in Your name, and do many mighty works in Your name?’ And then will I declare to them, ‘I never knew you; depart from Me, you workers of lawlessness'.
The lesson from this is that not all who are now numbered in the Kingdom of Heaven will be ready when Christ returns.
As a result, they will eventually be excluded from that Kingdom. The personal confession of faith should go hand in hand with the practice of a life from that faith; to ‘do the will of the Father’.
Jesus tells the parable of the wise and foolish virgins a few days before He is going to suffer and die on the cross.