The primary purpose of TDM is to optimize drug therapy, ensuring that the drug concentration remains within the target therapeutic range. This is essential for drugs with a narrow therapeutic index, where the difference between an effective dose and a toxic dose is small, such as digoxin and lithium. TDM helps prevent drug toxicity and ensures that the patient receives the maximum therapeutic benefit.