Ashes are a sign of penance and the beginning of a fast. You can find references to Ashes and sackcloth being adorned by penitents who were fasting and praying all over the Old Testament. Such as Jeremiah, Jonah, Esther, Judith, and Daniel. Isaiah also makes a reference to it, although he himself is not recorded doing it.
As for 40, in Judaism, this is considered the perfect number for preparation. We see the earth was purified for 40 days and nights by the waters of the great flood. We see that God gave the Ninevities 40 days to repent, and we see that our Lord fasted and prayed for 40 days before starting his public ministry. In the case of Lent we who have been baptized are preparing ourselves to renew our baptismal vows. I teach RCIA, my students are preparing to recieve the Easter Sacraments.