The quote is likely a misunderstanding of Einstein's view that "the important thing is not to stop questioning. Curiosity has its own reason for existing." This sentiment aligns with the idea that libraries, as repositories of knowledge, can be dangerous because they challenge existing beliefs and encourage questioning the status quo.
Therefore, the quote likely reflects the notion that exposure to diverse perspectives and ideas can be unsettling and even dangerous to those who cling to established views. It's not about the library itself being dangerous, but rather the potential for change and intellectual growth that it offers.
It's important to remember that this is a metaphorical interpretation of the quote, and there is no specific scene in "The Pursuit of Happyness" where this sentiment is expressed.