Table of contents
general method
proof of concept from Fano plane to obtain 7 by 7 case
the projective plane over F4 has 16+4+1 = 21 points and lines. Thanks to an explicit enumeration found here I could apply the previously described method. I used the Latin square 5x5 of OP, which is simply 3(x+y) mod 5. Each pair of points lie on a unique one of the 21 projective lines. Each projective line has 5 points and we can thus use 5x5 Latin squares there. Using always the same we construct a 21x21 Latin square. Because the enumeration at https://www.uwyo.edu/moorhouse/pub/planes/pg24.txt of the points is from 0 to 20, I kept that in final result, hence rows and columns are indexed from 0 to 20, not 1 to 21, but this is detail which can be changed.
Here is how one could go about it: you have 21 blocks B each of size 5x5.
For each such block B, you use \@namedef{Latin-i-j}{the value at row i and column j for the 5x5 Latin square with letters from B}. Your small Latin squares are idempotent so one the diagonal at i, i we simply have i. Each small Latin block defines 20 values off-diagonal.
So you need a loop over the 21 blocks B for each to define 20+5 macros (diagonal ones will be defined again by other blocks, but that's ok). Once done your big Latin square which contains 21 times 20 = 420 off-diagional elements plus 21 diagonal elements for a total of 441 = 21x21 pairs is prepared. The diagonal is known because your small Latin squares are idempotent.
You can then typeset it using a construct like this:
\documentclass{article}
\usepackage{array}
\usepackage{xinttools}
% YOU NEED HERE TO DO A LOOP OVER THE BLOCKS TO DEFINE SUITABLY
% (POSSIBLY EVEN BY SOME \numexpr FORMULA) THE 21 x 21 MACROS
% \makeatletter
% % some loop here over the block to define for each suitable
% % \@namedef{Latin-i-j}
% \makeatother
\edef\TwentyOneNumbers{\xintSeq{1}{21}}
\begin{document}
\makeatletter
\begin{tabular}{*{22}{c|}}
% first row
\xintFor* #1 in \TwentyOneNumbers\do{}\\
\hline
\xintFor* #1 in \TwentyOneNumbers\do{% this will be row number #1
#1
\xintFor* #2 in \TwentyOneNumbers\do{% this indices the columns
&\@nameuse{Latin-#1-#2}}
\\\hline}
\end{tabular}
\makeatother
\end{document}
The mwe above is lacking all the needed \@namedef because you did not explain what the blocks were (the 5x5 Latin square you gave is at first sight simply addition in Z/5Z up to renaming of indices). So currently we only get this:

the above table spills over right margin, but I didn't fix the page layout (which is very narrow in LaTeX default, better use package geometry). Also the columns are of varying widths which should be fixed. Finally, I took over inclusion of first row and first column from your 5x5 example, perhaps as Latin square these decorations should be removed to really ahve a 21x21 not 22x22 grid.
As proof of concept here is a construction a 7x7 Latin square base on the geometry of the Fano plane. The lines give our 7 blocks of each 3 elements.
For 3x3 idempotent Latin squares I chose addition modulo 3 (more precisely -x-y mod 3 to get idempotence). The formula can be implemented by a \numexpr expression. The \numexpr is tacit, because I use \xintAssignArray from xinttools, which defines a macro whose argument is automatically evaluated via \numexpr. This argument starts at 1 (the value 0 gives the number of elements of the array, here 3 in this application as blocks are of size 3).
Each pair of distinct elements from 1 to 7 is contained in a unique Block. Applying the recipe we construct a 7 by 7 Latin square.
In the general description I mentioned \@namedef but here I needed to expand argument, sadly LaTeX is extremely limited in terms of "programming", so I had to go to deeper lying TeX primitives for this bit.
In your specific case you seem to be aiming at 3 distinct 21x21 squares, so you need to adapt or repeat the procedure here by looping again over blocks.
\documentclass{article}
\usepackage{array}
\usepackage{xinttools}
% Take a pairwise design from Fano Plane
% I picked up the blocks at https://fr.wikipedia.org/wiki/Plan_de_Fano
% but I needed to shift by 1 the enumeration to manipulate 1, 2, ..., 7
% For each block, having 3 elements, I will construct an idempotent Latin
% square from addition modulo 3.
\xintFor #1 in {{1, 2, 4}, {2, 3, 5}, {3, 4, 6}, {4, 5, 7}, {5, 6, 1},
{6, 7, 2}, {7, 1, 3}}\do{%
\xintAssignArray\xintCSVtoList{#1}\to\aBlock
% arrays defined by \xintAssignArray are indexed starting at 1
\xintFor #2 in {0, 1, 2}\do{%
\xintFor #3 in {0, 1, 2}\do{%
% unfortunately LaTeX has very few programming tools,
% there is \@namedef but not even a \@nameedef
\expandafter\edef\csname Latin-\aBlock{#2+1}-\aBlock{#3+1}\endcsname
{\aBlock{2*(#2+#3)-3*((2*(#2+#3)+2)/3 -1)+1}}%
% this is crazy formula which simply does -(a+b) modulo 3
% which is same as 2(a+b) (we prefer non negative numbers with \numexpr)
% but a = i-1, b = j-1, and modulo is complicated with \numexpr
% (\numexpr is used by \aBlock to parse its argument)
% (this is property of "arrays" defined by \xintAssignArray)
}%
}%
}
% done, all our macros defined
\edef\SevenNumbers{\xintSeq{1}{7}}
\begin{document}
\makeatletter
\begin{tabular}{*{8}{c|}}
% first row
\xintFor* #1 in \SevenNumbers\do{}\\
\hline
\xintFor* #1 in \SevenNumbers\do{% this will be row number #1
#1
\xintFor* #2 in \SevenNumbers\do{% this indices the columns
&\@nameuse{Latin-#1-#2}}
\\\hline}
\end{tabular}
\makeatother
\end{document}

Now the real thing, using the 21-plane.
\documentclass{article}
\usepackage{geometry}
\usepackage{array}
\usepackage{xinttools}
% The projective plane over the field of 4 elements has
% 16+4+1 = 21 points.
% It also has 21 lines. Each pair of distinct points
% is contained in a unique line.
% A projective line has 4+1 = 5 elements and we can
% construct an idempotent Latin square using the field
% with five elements and the rule 3(x+y) modulo 5
% as 6x is same as x modulo 5. This is indeed exactly the
% rule in the OP's example of Latin square.
% Thus we will get a 21x21 Latin square from that, simply
% by enumerating the 21 projective lines in the projective
% plane over F_4.
% We need a list of those lines, with the points of the plane
% are suitably enumerated. Thankfully, we found one at
% https://www.uwyo.edu/moorhouse/pub/planes/pg24.txt
% 0 1 2 3 4
% 0 5 6 7 8
% 0 9 14 15 16
% 0 10 12 17 19
% 0 11 13 18 20
% 1 5 9 10 11
% 1 6 14 17 18
% 1 8 13 16 19
% 1 7 12 15 20
% 2 5 14 19 20
% 4 5 13 15 17
% 3 5 12 16 18
% 2 6 9 12 13
% 2 7 11 16 17
% 2 8 10 15 18
% 3 6 11 15 19
% 4 6 10 16 20
% 4 7 9 18 19
% 3 8 9 17 20
% 4 8 11 12 14
% 3 7 10 13 14
% Our points are enumerated from 0 to 20.
% I manipulated it using search/replace in an Emacs buffer into
% nice format for input to \xintFor and \xintAssignArray
\xintFor #1 in {%
{0}{1}{2}{3}{4},
{0}{5}{6}{7}{8},
{0}{9}{14}{15}{16},
{0}{10}{12}{17}{19},
{0}{11}{13}{18}{20},
{1}{5}{9}{10}{11},
{1}{6}{14}{17}{18},
{1}{8}{13}{16}{19},
{1}{7}{12}{15}{20},
{2}{5}{14}{19}{20},
{4}{5}{13}{15}{17},
{3}{5}{12}{16}{18},
{2}{6}{9}{12}{13},
{2}{7}{11}{16}{17},
{2}{8}{10}{15}{18},
{3}{6}{11}{15}{19},
{4}{6}{10}{16}{20},
{4}{7}{9}{18}{19},
{3}{8}{9}{17}{20},
{4}{8}{11}{12}{14},
{3}{7}{10}{13}{14}}\do{%
\xintAssignArray#1\to\aBlock
% arrays defined by \xintAssignArray are indexed starting at 1
\xintFor #2 in {0, 1, 2, 3, 4}\do{%
\xintFor #3 in {0, 1, 2, 3, 4}\do{%
\expandafter\edef\csname Latin-\aBlock{#2+1}-\aBlock{#3+1}\endcsname
{\aBlock{3*(#2+#3)-5*((3*(#2+#3)+3)/5 -1)+1}}%
% this is crazy formula which simply does 3(a+b) modulo 5
% but recall it is a+1 and b+1 which serve as arguments to
% the array \aBlock
}%
}%
}
% done, all our macros defined
\edef\TwentyOneNumbersStartingAtZero{\xintSeq{0}{20}}
\begin{document}
\makeatletter
\begin{tabular}{*{22}{c|}}
% first row
\xintFor* #1 in \TwentyOneNumbersStartingAtZero\do{}\\
\hline
\xintFor* #1 in \TwentyOneNumbersStartingAtZero\do{% this will be row number #1
#1
\xintFor* #2 in \TwentyOneNumbersStartingAtZero\do{% this indices the columns
&\@nameuse{Latin-#1-#2}}
\\\hline}
\end{tabular}
\makeatother
\end{document}

2(2x+y)this would be\aBlock{2*(2*#2+#3)-5*((2*(2*#2+#3)+3)/5 -1)+1}and for2x-yit would be\aBlock{(2*#2-#3)-5*((2*#2-#3+3)/5 -1)+1}. The crazyness is in part caused by\numexprdivision which rounds rather than truncating. – Nov 14 '17 at 22:27/does not behave like you expect. In numexpr for example3/5gives1and2/5gives0. It rounds up. Thus(a+3)/5-1is magic formula to get euclidean quotient ofaby 5. Hence the modulo will bea - 5*((a+3)/5-1). So the formulas above implement2(2x+y)and2x-ybut there is the additional twist that macro\aBlockwants its argument to be over the range1, 2, 3, 4, 5. The#2and#3are already looping from0to4, hence the code contains\aBlock{#2+1}to recover the block elements, etc.., – Nov 14 '17 at 22:39+1in the formula above to go frommod 5to1, 2, 3, 4, 5. A propos magic formula(a+3)/5-1one has to be careful thatahas to be non-negative. So the(2*#2-#3)-5*((2*#2-#3+3)/5 -1)+1is wrong, one must use(2*#2+4*#3)-5*((2*#2+4*#3+3)/5 -1)+1. Python language has periodic modulo but this fails in other languages and in particular with eTeX's\numexprdivision and one has to pay attention to sign of argument. – Nov 14 '17 at 22:392x-y mod 5is same as2x+4y = 2(x+2y) mod 5, which was indeed among listed possibilities:)... and as explained in previous comments for matter of modulo computations with numexpr, one must avoid negative numbers which add their own twists, so2(x+2y)is to be preferred anyhow... – Nov 15 '17 at 08:31