Edwin R. answered 01/20/24
DMD/PhD Dental Student with 8+ Years tutoring Organic Chemistry
When considering which nitrogen heterocycle is more basic, we need to look at which nitrogen donor atom delocalizes its electrons in the molecule the least. The more delocalization, the lower the rate at which the nitrogen donor atom snatches a proton (H+) from an acid. Option B is the strongest base and will snatch a proton (H+) with the fastest rate. This is because the lone pair of electrons on the nitrogen atom is unable to delocalize...in other words it is localized. Options A, C, and D have nitrogen atoms which are able to delocalize around the rings.
Bottom line: The more delocalization a lone pair of electrons can undergo from the nitrogen atom, the less basic the nitrogen atom (lower rate of accepting an H+).