Most small-molecule drugs work by binding to a protein. The protein — called the target — is a large folded chain of amino acids with one or more pockets on its surface where small molecules can sit. The drug is a small organic molecule, typically under about 500 daltons, small enough to be absorbed and to reach the protein inside the body.
Binding means the drug settles into a pocket and stays there long enough to matter. It is held by weak, reversible interactions — hydrogen bonds, hydrophobic contact, electrostatic attraction — not by a permanent chemical bond. Because the interactions are weak, the fit has to be good: the drug's shape and the chemical character of its surface must complement the pocket, the way a key matches a lock. A molecule that is the right size but the wrong shape simply does not stay.
Once bound, the drug changes what the protein does. If the target is an enzyme that produces a disease-driving signal, an occupying molecule can block the site where the real substrate would bind, slowing that production. If the target is a receptor, the drug may switch it off or dampen its response. The disease effect follows from that change in protein behaviour, not from the drug acting on the disease directly.
This is why the search is so specific. The requirement is not "a molecule that is active" but "a molecule that fits this particular pocket well enough to alter this particular protein, and does not fit the thousands of other pockets in the body well enough to cause trouble."