The origin of this feast is similar to that of the Blessed Sacrament. The symbolism surrounding the wound in the side of Jesus made by the lance of Longinus, from which flowed blood and water, was already familiar to the early Fathers of the Church. There are wonderful pages in the writings of St. Augustine and St. John Crysostom about the Church which, radiant with youth, springs from the side of the new Adam asleep upon the cross, as well as about the divine sacraments which flowed from the loving Heart of the Redeemer.
This tradition of the Fathers was preserved and developed by the Benedictine school of piety; so that when, finally, in the 12th Century, St. Bernard directed the mystical devotion of his monks of Clairvaux towards a special cultus of the human nature of the Savior, the devotion to the Sacred Heart after the manner now paid to it by the Liturgy many be said to have come into being. From simply meditating on the wounds of Jesus, the Benedictine mystics had developed a special devotion to that in His side, and entering through the opening made by the lance of Longinus, had penetrated to his very Heart wounded by the lance of love.
(Source: The New Roman Missal by Father Lasance).