The original Saint Valentine, says the legend, was a healer in Rome, and like all Christians, subject to persecution by the Empire. One of the local jailers had sought him out, seeking a cure for his daughter, blind from birth. Valentine took her on as a patient, eventually as a student as well, and while she made no progress on the vision front, she learned the ways of the new religion. Early in 270, Valentine was arrested and condemned, and the jailer, helpless in the face of the orders of the Emperor, agreed to carry one last message back to the girl, urging her to hold fast to her faith. When she opened the envelope, she discovered a slip of paper saying "From your Valentine", and a yellow crocus and, most miraculous, she was able to see them both.
How much of this is true and how much of it is simple counterprogramming will never be known for certain. The Romans had their own mid-February festival, called Lupercalia, notable for its element of random sexuality: the names of available women were put into a hat, or something very much like a hat, and men would perforce draw them out. In keeping with standard Christian practice, the feast of St Valentine's Day, proclaimed by Pope Gelasius I in 496, was timed to draw as many people as possible away from that horrid pagan business. As usual, it didn't work that well; people incorporated the new practices into the old festival, and went on as before.