Locally repairable codes (LRCs) with (r,t)-locality could provide the requirements of local repair and parallel reading in distributed storage systems, which has attracted extensive attention. At present, LRCs with (r,t)-locality are seldom able to achieve the optimal minimum distance and optimal code rate at the same time, therefore, this paper proposes a construction algorithm of LRCs based on Latin square. More specifically, the digits in Latin square are replaced by binary numbers according to certain rules, and then the required check matrix can be constructed by the Kronecker product. Thus, binary locally repairable codes (BLRCs) with (r,2)-locality of information symbols are constructed. Furthermore, a construction algorithm of LRCs based on Mutually Orthogonal Latin Squares (MOLS) is proposed, which could construct BLRCs with arbitrary availability. Theoretical analyses show that, both of the two constructed codes satisfies the minimum distance bound, and their code rates are higher than that of the LRCs constructed based on direct product codes and array LDPC codes, and the LRCs based on Latin square achieve the optimal code rate.