Locate the lone pair before comparing bases
An aromatic ring containing nitrogen does not automatically make that nitrogen unable to accept a proton. The key question is whether its lone pair supplies electrons to the aromatic π system.
Pyridine: the lone pair lies outside the π system
Pyridine has a six-membered aromatic ring. Its nitrogen contributes one electron from a p orbital to the π system, while the lone pair occupies an orbital in the ring plane. Using that lone pair to bind a proton preserves the aromatic electron count.
Pyrrole: the lone pair completes the aromatic sextet
Pyrrole has a five-membered ring with two double bonds. Those bonds supply four π electrons, and the nitrogen lone pair supplies two more. Protonating nitrogen would remove that pair from the aromatic system, making proton acceptance at nitrogen much less favorable.
This explains why pyrrole nitrogen is much less basic than pyridine nitrogen. It does not mean pyrrole cannot react with acids or other electrophiles; reactions at ring carbons are a separate issue.
A transferable check
Draw the lone pairs, count the aromatic π electrons, and redraw the proposed protonated structure. Compare what stabilization is retained or lost before ranking nitrogen basicity. Solvent and substituents still matter.
Related question
Apply this knowledge
Use the concept guide to understand the reasoning, then return to the complete question and worked answer.
Why Are Alkylamines More Basic Than Arylamines?Sources
These references support the core concepts and interpretation boundaries explained above.