A fully algebraic and robust two-level Schwarz method based on optimal local approximation spaces