This is a very sophisticated question, as the Old Testament has many sources. In fact, scholars debate which sources are the most reliable. The best approach is to use all the sources at once. In light of this, the three most important sources are as follows:
- MT - The Masoretic Text was created by a group of Jewish scribes, from the Middle Ages. They were called Masoretes and the best and oldest manuscripts we have from them dates to around 1000 AD. However, what these texts reflects probably go back to around 100 AD. I should also add that they were extremely careful.
- DDS - The Dead Sea Scrolls were found in 1947 in various caves. Most importantly they date to 200-100 BC, that is, a thousand years earlier than our Masoretic texts. It is important to note that the DDS confirms the MT. This shows how careful the Masorites were in their copying.
- LXX - Septuagint. Greek translations started around 300-200 B.C. We can read an account of the Greek translation of the Hebrew Bible in the Letter of Aristeas. Since these texts are old, some scholars want to the use the LXX to challenge the MT readings. In theory this is possible, but textual criticism is no easy thing, as you can imagine.
There are, of course, other sources, like the Samaritan Pentateuch, but the above three are the most common. Finally, I will add a link on textual criticism.