ANSWER: The tradition of casting lots is in the Bible several times. They are thought to have been used in 1Samuel 14:40 - 42. In this case, however, it is not the lots but rather the Urim and Thummim used to render a decision. According to the first century Jewish historian Josephus, the Urim was composed of two sardonyx stones, each one within a pouch in the Breastplate worn by the High Priest. This breastplate is known as the breastplate of judgment. That said, the practice of lots was used frequently in ancient Israel.
The primary reason for casting lots was to render an impartial, unbiased decision on important matters. Once they were cast, no one could argue that the decision was the result of human intervention like nepotism, politics, favoritism, and so on. This practice would be the same as throwing dice or flipping a coin we commonly use today. In ancient times, they used varying means to cast lots, depending on the place and local customs, such as coins, polished sticks, cards, dice, and so on.
What is particularly significant is the fact that, in ancient Israel, the High Priest did use from time to time the tradition of casting lots for important, uncertain decisions. It amounted to consulting God for the answer, as Proverbs states "The lot is cast into the lap, but its every decision is from the Lord" (Proverbs 16:33).
This impartial practice stops arguments and contentions between people (and no doubt could prevent them from occurring in the first place). The book of Proverbs states that "Casting lots causes contentions to cease, and keeps the mighty apart." (Proverbs 18:18). The last written case in the Bible of its use is in Acts chapter 1, when the apostles asked for God's decision regarding the choice between two men to replace Judas.
26 Then they drew lots (other translations have 'cast lots') to choose between the two men, and the one chosen was Matthias . . . (Acts 1:26)
It has been an ancient practice for people to take upon themselves to inquire about things unknown through mediums, readers of cards, palm readers, diviners, etc. God condemns, as made abundantly clear in Deuteronomy 18, these occult practices. There is nothing wrong with flipping a coin or using some similar method to select something or determine a winner. When done, however, it is important to remember that chance produces the outcome and nothing else. I hope this answers your question about the practice of casting lots in the Bible.