Entanglement in curved spacetimes and cosmology