Lent was originally a Germanic word for the season of Spring and the Anglo-Saxon word for the month we call March. The word "Lent" may come from older words meaning "longer days", because the days get longer in the spring. In the ancient and medieval worlds, Lent was the hungriest time of the year, after you had already eaten most of the food stored for the winter, and before anything new was growing yet in the spring.
Beginning about the time of Constantine, roughly 300 AD, Christians began to think of Lent as the period of forty days before Easter. In Early Medieval Europe, Christian bishops told Christians that God wanted them to fast - to eat very little food - for forty days before Easter. This was so you could share in the suffering of Jesus when he was being crucified, and so you would deserve to be saved by the sacrifice that Jesus made for you. You were also supposed to pray more than usual. This period of fasting helped people make their food last until spring, while feeling like they were doing something good instead of just being hungry.
Lent lasts for forty days because that's a very common number in the Bible - the Flood lasted for forty days, the Jews wandered in the wilderness for forty years, Jesus spent forty days in the desert, and so on.
In both pagan and Christian traditions, Lent ends at Easter with a big feast to celebrate. Christians think of their Easter dinner as celebrating the rebirth of Jesus, and pagans thought of it as celebrating the first new food of the spring. Jews thought of it as their Passover, celebrating their escape from slavery in Egypt. All of these people eat the same early spring foods at Easter - lamb, eggs, parsley, rabbits, and barley bread.