This is something that you say when you suspected or guessed something, and then find out that you were correct. For example, when you thought that you were going to fail a test, and it comes back with a failing grade, you can say to yourself:
Crap! I knew it!
You can say "I knew it!" about either positive or negative situations.
It's pronounced with a strong stress on the word "knew".