Then why did Jesus say “It is finished” when He was on the cross and what was he referring to?
Remember what feast Christ was celebrating with His Apostles... Passover. They celebrated the first three cups in the upper room. The third cup (the cup of blessing) was the cup noted in the Synoptic Gospels. Jesus said He would not taste of the fruit of the vine again until He did so in His Kingdom. The Gospel then tells us they went out to the Garden of Gethsemane... but there was no fourth cup as is usual in the Passover meal (the cup of completion). In fact, Jesus prayed in the garden that this cup might pass Him by.
Now, Christ begins to offer Himself as the Passover Lamb. This is the Feast of the Unblemished Lamb. In this, the celebrant flays open the back of the lamb and holds it up so that the participants can see there are no blemishes. Just so, Christ's back was flayed open at the command of Pilate and Pilate also declared "I find no fault in Him." Christ was taken and killed on the Cross... but no bones were broken as was required of the Passover lamb. When His sacrifice was complete, He finished the Passover celebration of His own offering by asking for the hissop. Immediately after, He declared it (the Passover meal) finished and offered up His Spirit. His destiny is complete... He has offered Himself for us... it is finished. But it is not truly the end. If it was, there would be no resurrection!
Catholics see this as the first Mass. In the Mass, there is a homily. You can find Christ's homily in His exclamation, "My God, My God. Why have You foresaken me?" God did not abandon Christ on the Cross. There was no time in His Life that He was more adorable to His Heavenly Father than when He was fulfilling His destiny on the Cross! No, He was calling His witnesses to Psalm 22 to understand what they were seeing. It begins in agony but ends in triumph. These are His words from the Cross with the little breath He has. The unique nature of the exclamation and the beginning of the Psalm are not a coincidence.