The Justice Department is preparing to recommend to Congress that lawmakers adopt new legislation that holds Facebook, Google and Twitter liable for a wide array of content posted online, eroding a long-cherished legal immunity that Silicon Valley says is critical to the future of the internet.