The same way we do, by faith; faith in God the Creator who lives, faith in His ability to bless the righteous and punish evildoers, and faith that Messiah would come.
They had faith if they kept the Law, as handed down by God to Moses, with a pure heart, they would be acceptable to God. Those Old Testament believers were assured they would be welcomed into heaven, for King David wrote in Psalms, “For the Lord loves justice and does not forsake His saints, they are preserved forever.
”God used Moses to bring the Law to His people to show them what sin was and what they needed to do in response to their sin. The various sacrifices were ordered by God to cover the sins of the people and had to be repeated every year. The Law made nothing perfect. Those sacrifices were done as a reminder of sin, but they were insufficient to make a person holy and acceptable to God. The Law was weak and unprofitable, according to the writer of Hebrews, and so were the sacrifices. These Old Testament saints were saved by faith, not by keeping the Law.
Before the Law, in the days of Adam and Abel, and Noah and Abraham, and Aaron and Moses, people were still saved by faith. Noah was considered righteous by God according to his faith. Abraham, Isaac, and Jacob died in faith, not having received the promises but having seen them in the distance. Moses chose to suffer with his people looking to the reward, rather than stay in Egypt and enjoy the temporary pleasures of sin. These guys walked the difficult road that leads to life. The rest of the world chose the easy way leading to destruction. These Old Testament saints were saved by faith because they knew that without faith it is impossible to please God.