In a nutshell: in order to pass through the blood-brain barrier (BBB) the substance has to mimick soee properties of the substances that are allowed to pass through.
There are different types of "transporters" -- integral proteins going through the cell membranes and accounting for the active transport of the substances they can actively bind to. Smaller molecules of drugs can use solute carrier transporter (SLC), whereas bigger molecules (oligo- and polymeres) would use the receptor-mediated transporter (RMT).
There is a nice article on this topic published by ScienceDaily.
Here is the quote:
One technology for enabling active transport of small molecule drugs
across the BBB involves targeting endogenous nutrient transporters.
These transporters are members of the solute carrier (SLC) transporter
superfamily. Transport of small molecules across the BBB by these
membrane proteins is known as carrier-mediated transport (CMT).
In order to design drugs that utilize CMT to cross the BBB,
researchers modify their chemical structures so that they resemble
nutrients that are transported across the BBB by specific SLCs. The
prototypical drug that uses this strategy (which was developed long
before mechanisms of CMT were known) is L-DOPA, the major current drug
for Parkinson's disease. L-DOPA is used to replace dopamine that is
lost due to degeneration of dopaminergic neurons in the substantia
nigra of the brain.
Another major system that is used in normal mammalian physiology to
enable needed molecules to cross the BBB is receptor-mediated
transport (RMT). The brain uses RMT to transport proteins, peptides,
and lipoproteins that are needed for brain function across the BBB.
Examples of biomolecules that are transported into the brain via RMT
include insulin, insulin-like growth factor (IGF), leptin,
transferrin, and low-density lipoprotein (LDL).
In RMT, molecules in the circulation may bind to specific receptors on
the luminal surface of brain capillaries (i.e., the surface that
interfaces with the bloodstream). Upon binding, the receptor-ligand
complex is internalized into the endothelial cell by a process called
receptor-mediated endocytosis. The ligand may then be transported
across the abluminal membrane of the endothelial cell (i.e., the
membrane that interfaces with brain tissue) into the brain. This whole
process is called receptor-mediated transcytosis.