The tradition of casting lots is referenced several times in the Bible. Although they are thought to have been used in 1Samuel 14:40 - 42, when King Saul sought God's counsel, they were not. In this case, what was cast was not lots but rather the High Priest's Urim and Thummim used to render a decision.
The primary reason for casting lots was to render an impartial, unbiased decision on important matters. Once the lot was cast, no one could argue that the decision was the result of human intervention like nepotism, politics, favouritism, and so on.