I could not pass the exam.
This is either a simple statement that the speaker was unable to pass the exam in the past, or that the speaker contemplates being unable to pass the exam in the future.
Why aren't you practicing law nowadays?
-- I tried, but I could not pass the bar exam.
Why don't you consider becoming a lawyer?
-- I could not pass the bar exam.
I could not have passed the exam.
This is a more complicated statement, which refers to the past inability to pass the exam, but as viewed in hindsight in relation to a counterfactual circumstance. For example:
I had had no sleep the night before the exam because the people living in the room above me were partying all night. So I could not have passed that exam no matter how well I knew the subject matter. I was falling asleep at my desk!
The phrase no matter how well I knew the subject matter refers to a counterfactual situation, one where the speaker postulates having perhaps even an expert's knowledge of the material. Even if he had been an expert on the subject, he could not have passed the exam because of his lack of sleep the night before.