You’re right when you say that God knows we’re not perfect, because He knows all about us—not only what we do but what we think. The Bible says, “Everything is uncovered and laid bare before the eyes of him to whom we must give account” (Hebrews 4:13).
Why, then, doesn’t God simply ignore it when we do something wrong? One reason is because He knows what happens to us when we sin: it always—without exception—ends up hurting us. And because God loves us, He doesn’t want this to happen. God’s way is always best, and when we deliberately choose to ignore Him and go our own way, eventually we’ll pay the price for our disobedience. But this grieves the heart of God, because He loves us and wants what is best for us.
Think of it this way. If you lived on a busy street, wouldn’t you warn your children to keep out of it? Of course you would—and if they disobeyed you, you wouldn’t ignore it or simply say, “Oh well, children will be children.” Instead you’d do everything you possibly could to keep them from doing it again—because you love them. The same is true with God.
I’m curious, however, why you’ve asked this question. Is it because you have chosen to go your own way in life—and you hope God doesn’t care? But He does care—because He loves you. He loves you so much that Jesus Christ came into the world to give His life for you. Put your life into His hands today.