God knowing how others think does not mean God thinks the way others think. The Bible tells us:
“‘For My thoughts are not your thoughts,
Nor are your ways My ways,’ declares the Lord.
‘For as the heavens are higher than the earth,
So are My ways higher than your ways
And My thoughts than your thoughts.’” (Isaiah 55:8-9)
In order for God to be all-knowing, He must know the thoughts of others. This includes knowing even Satan’s thoughts. If He did not know these things, then God would not be omniscient. However, knowing Satan’s thoughts does not mean God is in any way influenced by those thoughts or thinks the way Satan does.
God’s thoughts are perfect and good, but Satan’s thoughts are evil and human thoughts are often evil too. And God does not think like Satan or humans. His thoughts are much, much higher.
Knowing good and evil for God means knowing the difference between good and evil. While God is all-good, He knows that evil is not good, a deviation from good, and a falling short of God’s glory.
That is why the Bible also says, “All have sinned and fall short of the glory of God…” (Romans 3:23).
This means humans don’t measure up. So God knows that humans don’t measure up to His goodness. And God knows the difference between good and evil.
---
“Let no one say when he is tempted, ‘I am being tempted by God’; for God cannot be tempted by evil, and He Himself does not tempt anyone. But each one is tempted when he is carried away and enticed by his own lust.” (James 1:13-14)
Although God allows people to be tempted in order to test them, God does not tempt anyone because He cannot be tempted by evil. God the Father allowed God the Son to undergo testing in the wilderness so that Jesus can prove to the world that God cannot be tempted.
“For we do not have a high priest who cannot sympathize with our weaknesses, but One who has been tempted in all things as we are, yet without sin.” (Hebrews 4:15)
Note that Jesus underwent temptations by Satan (not God) in the wilderness: “Then Jesus was led up by the Spirit into the wilderness to be tempted by the devil” (Matthew 4:1).
So God does not exempt anyone from being tested, even His own Son. In allowing His Son to undergo temptations, God proves that His Son is perfect and without sin, and able to be the perfect Lamb of God who takes away our sins.
---
Jesus said the devil “was a murderer from the beginning, and does not stand in the truth because there is no truth in him. Whenever he speaks a lie, he speaks from his own nature, for he is a liar and the father of lies” (John 8:44).
So Jesus knows the devil’s thoughts – that they are thoughts of murder and lies. But Jesus does not think the same way the devil does.
In fact, God’s thoughts go so much higher that He is able to outsmart the devil and people who think evil thoughts. God is astute and is the righteous Judge. So He knows how everyone thinks. His judgements are righteous and true and done in such a way that no one can argue with Him.
“But He detected their trickery…And they were unable to catch Him in a saying in the presence of the people; and being amazed at His answer, they became silent.” (Luke 20:23,26)
In order to judge anyone, God has know what they have done and what their thinking processes were. But knowing these things, God proves Himself astute in judgement so that He can be the wise and righteous Judge of all.
“With the kind You show Yourself kind;
With the blameless You show Yourself blameless;
With the pure You show Yourself pure,
And with the crooked You show Yourself astute.” (Psalm 18:25-26)
If anyone thinks he is wise in his craftiness and can outsmart God, he will be proven wrong.
"If any man among you thinks that he is wise in this age, he must become foolish, so that he may become wise. For the wisdom of this world is foolishness before God. For it is written, 'He is the One who catches the wise in their craftiness'; and again, 'The Lord knows the reasonings of the wise, that they are useless.'" (1 Corinthians 3:18-20)
So from these things, you can be sure that God is righteous and perfect. Even though God knows what we think and how we think, He doesn't have the same thoughts we do, and He doesn't think the way we do or the way the devil does. His thoughts are righteous and pure. His thoughts and ways are much, much higher!
“The Lord is righteous in all His ways
And kind in all His deeds.
The Lord is near to all who call upon Him,
To all who call upon Him in truth.” (Psalm 145:17-18)
“This is the message we have heard from Him and announce to you, that God is Light, and in Him there is no darkness at all.” (1 John 1:5)
“Your heavenly Father is perfect.” (Matthew 5:48)
---
Another way of thinking about this is if we have an analogy.
You know you should not steal. But someone who plans to steal something tells you that they plan to steal something. Does your knowledge of that person's plans make you evil?
No it doesn't. As long as you don't steal, you are not a thief like the other person.
So also God is not evil for knowing the thoughts of the wicked, because He does not think or act like the wicked.