John 12:40 literally reads:
[He] has blinded their eyes and hardened their heart, in order that they
would not see with their eyes and understand with their heart, and
turn, and I would heal them.
A parallel passage also seems to exist in Matthew 13:14-15. Slight manuscript variance exists, but the variant readings have little significance for translation in this passage (since textual analysis is not the primary objective of this response, I will elaborate no further). A parallel passage also exists in Matthew 13:14-15, which could be used to illumine information about the source that was used for Isaiah's prophecy (but this will not be done for this response due to its focus on meaning, since this analysis sheds little additional light on the meaning of this verse).
The Basic Meaning
The immediate context of this passage tells us that the Jews refused to believe in Jesus despite him having performed many miracles (v. 37). It specifically states that this was so that the word of the prophet Isaiah would be fulfilled (v. 38). This is an apparent reference to Isaiah 6:9-10, which is then quoted (vv. 38-40). John 12:40 is thus a quote of Isaiah 6:10. John 12:41 goes on to interpret this passage of Isaiah as being a response to having seen "his glory" (presumably Jesus' glory based on the context). In Isaiah 6, the prophet sees the Lord sitting on a throne, who he calls the "King, the LORD of hosts." After exclaiming that he is a man of unclean lips among a people of unclean lips, a seraphim flies to Isaiah and touches a burning coal from the altar to his lips, and states that Isaiah's "guilt is taken away," and his "sin atoned for."
In John 12, the author is equating the Lord/LORD of Isaiah's vision with Jesus Christ. The Jews' unbelief in the context of this passage is seen as fulfillment or continual evidence of Isaiah's prophecy concerning God's people (they refused to turn to God). The implication also seems to be that God is the cause of (or at least a contributor to) the Jews' blindness and hardness of heart (getting into this any further would be impossible without introducing significant doctrinal speculation).
A deeper and more nuanced meaning could no doubt be argued on the basis of the entire relevant context of the passage in Isaiah by comparison to the situation in John's gospel, but this would be exhaustive and beyond the scope of John 12:40.1
1 If you are interested in how early Church Fathers interpreted this passage, St. Augustine writes extensively on this passage when discussing predestination in:
Augustine of Hippo, "A Treatise on the Gift of Perseverance", trans. Robert Ernest Wallis In , in A Select Library of the Nicene and Post-Nicene Fathers of the Christian Church, First Series, Volume V: Saint Augustin: Anti-Pelagian Writings, ed. Philip Schaff (New York: Christian Literature Company, 1887), 539. This can be read online for free.
He also writes about it in Tractate LIII:
Augustine of Hippo, "Lectures or Tractates on the Gospel According to St. John", trans. John Gibb and James Innes, in A Select Library of the Nicene and Post-Nicene Fathers of the Christian Church, First Series, Volume VII: St. Augustin: Homilies on the Gospel of John, Homilies on the First Epistle of John, Soliloquies, ed. Philip Schaff (New York: Christian Literature Company, 1888), 291-95. This can be read online for free.
For an alternate perspective free from the lens of predestination and divine determinism, see St. John Chrysostom's homily on these verses:
John Chrysostom, "Homilies of St. John Chrysostom, Archbishop of Constantinople, on the Gospel of St. John", trans. G. T. Stupart In , in A Select Library of the Nicene and Post-Nicene Fathers of the Christian Church, First Series, Volume XIV: Saint Chrysostom: Homilies on the Gospel of St. John and Epistle to the Hebrews, ed. Philip Schaff (New York: Christian Literature Company, 1889), 252-53. This can be read online for free.
Several other early Fathers discuss or reference this passage, but Augustine and Chrysostom represent the main two streams of thought (Chrysostom's thought was more common in the early Church, Augustine became popular along with his views on original sin and predestination later in history in the Western Church).