Entering into "God's rest" is by faith. That is how it was with the forefathers of the Israelites, back in the time of Moses. That continued to be the way of entering in for Christians in the first century. That is why the writer to those Hebrew Christians drew their attention to how their forefathers failed to enter into that rest in the previous chapter and right through to the verse you ask about.
The determining factor for not entering into God's rest was a hardening of their hearts in the wilderness, when they tested God. They had the promised land ahead of them, the assurance of God's word that it would be theirs and they would know rest from all their enemies around if they obeyed the Lord. But they disobeyed. And some did not enter in. Indeed, the generation that got to the edge of the promised land but who then disbelieved God's assurance of taking them in died in the wilderness. They lacked faith in God.
After detailing the provocation of that unbelieving generation, the Holy Spirit is recorded as saying, "Harden not your hearts, as in the provocation, in the day of temptation in the wilderness: when your fathers tempted me, proved me, and saw my works forty years. Wherefore I was grieved with that generation, and said, They do always err in their heart; and they have not known my ways. So I sware in my wrath, They shall not enter into my rest." (3:7-11)
Where there is believing, obedient faith, there is no hard, evil heart. That is why the foregoing is applied to Christians this way:
"Take heed, brethren, lest there be in any of you an evil heart of
unbelief, in departing from the living God. But exhort one another
daily, while it is called To day; lest any of you be hardened through
the deceitfulness of sin." (3:12-13 K.J.V.)
It is the promise of entering into God's rest that has to be kept before the believer, so that faith in God always keeping his promise strengthens faith. Then no matter what temptations to sin come along, the believing heart will not miss a beat.
Verse 12 in chapter 12, which you also ask about, shows the key role of the inspirational nature of God's word which "is a discerner of the thoughts and intents of the heart". Matters of faith, belief and obedience are known to God, and we know of them through believing God's word to be inspired of God. We can deceive ourselves, but God is never deceived, so we need to submit our whole being, including our mind and our heart, to the judgment of God's sacred word. We have to be open to the refining power of God's word:
"Is not my word like as a fire? saith the Lord; and like a hammer that
breaketh the rock in pieces?" Jeremiah 23:29
If that unbelieving generation had submitted to the power of God's word to them, they would have kept faith and entered into rest instead of being broken in pieces like a rock. The application is just the same in the Christian era. Each generation of believers must submit to the power of God's word to them, to be refined by it, then they will keep faith and enter into God's rest. It's all about faith, then we will enter into that rest and not fall beforehand due to unbelief.
EDIT: In Summary - Because this answer tries to confine itself to the one verse in question, it must, of necessity, fall short of a full answer about the vast scope of what it means to enter into God's rest. The verse involves the failing of the Mosaic generation to enter into God's rest back then, which serves as the warning for others and for us not to let lack of faith and sin cause us to fail (or to stumble and fall). But when a believer puts full faith in Christ's finished work on the cross, that is when God's spiritual rest begins for that person, personally, as they then rest from their own works, or efforts, to 'earn' God's approval. Their conscience is cleared and, as they keep walking in faith and obedience, they know the continued peace of God, which is rest for their souls as they labour for the Master, with joy. This is the sweet fore-taste of the full rest of heaven yet to come, in heaven. Experiencing that, the faithful believer is kept from falling away, while the merely intellectual believer may not last the course as that is not faith. This answer, however, is restricted by only one verse being asked about.