Answer:
To provide << operator access to non-public members of the class.
Explanation:
Whenever we overload << operator, an object to ostream class has to be passed as this is the class which has properties which allows printing of output to console. Moreover, this operator is used outside class all the time so if not made a global member it will produce conflicts so thats why it has to be made a friend function to allow efficient access to private members of the class. Its declaration inside class is as follows :
friend ostream& operator<<(std::ostream& os, const T& obj) ;