Great question! We are using the modal "should" in the past. The best way to think about this is that most modal verbs (should, would, might, may, could) can be used to talk about the past, but when they do, they must take "have" + the past participle. You cannot use "had" here, nor the past simple (you can't say "should had known" or "should knew").
This is a very common construction. Using modals in the past is very important, especially for expression regret, as in a third conditional:
If I had known, I would have done something.