How can I print this equation properly?

Some comments about your code:

  • First and foremost, get rid of all blank lines in the math environments.

  • I don't think that it is correct, typographically speaking, to use \cdots as the typographic ellipsis in all places in the matrices. In rows 1, 2, and 4, it should be \dots (or \ldots). In row 3, three of the four \cdots instructions really ought to be \vdots; the 3rd out of four, though, should be \ddots.

  • The subscript notation in the Q matrix in row 1 is not well designed. E.g., instead of 1p+1 and p+12, do write 1,p+1 and p+1,2, etc.

  • The transpose notation you employ in the first matrix in the second row is not well chosen. I suggest you place the transpose symbol -- whether ^t, ^{\prime}, ^{\top}, or whatever strikes your fancy -- between the two vectors.

enter image description here

\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry} % set page dimensions appropriately
\usepackage{amsmath} % for 'align*' and 'pmatrix' environments
\begin{document}

\begin{align*}
H 
&= \begin{pmatrix}
1 & x_{11} & \dots & x_{1p} \\
1 & x_{21} & \dots & x_{2p} \\
\vdots & \vdots & \ddots & \vdots \\
1 & x_{n1} & \dots & x_{np}
\end{pmatrix}%_{\!\!\!n\times(p+1)}
\begin{pmatrix}
q_{11} & q_{12} & \dots & q_{1,p+1} \\
q_{21} & q_{22} & \dots & q_{2,p+1} \\
\vdots & \vdots & \ddots & \vdots \\
q_{p+1,1} & q_{p+1,2} & \dots & q_{p+1,p+1}
\end{pmatrix}%_{\!\!\!(p+1)\times(p+1)}
\begin{pmatrix}
1 & 1 & \dots & 1 \\
x_{11} & x_{21} & \dots & x_{n1} \\
\vdots & \vdots & \ddots & \vdots \\
x_{1p} & x_{2p} & \dots & x_{np}
\end{pmatrix}%_{\!\!\!(p+1)\times n}
\\
&= \begin{pmatrix}
x_{1}{}'q_{1} & x_{1}{}'q_{2} & \dots & x_{1}{}'q_{p+1} \\
x_{2}{}'q_{1} & x_{2}{}'q_{2} & \dots & x_{2}{}'q_{p+1} \\
\vdots & \vdots & \ddots & \vdots \\
x_{n}{}'q_{1} & x_{n}{}'q_{2} & \dots & x_{n}{}'q_{p+1}
\end{pmatrix}
\begin{pmatrix}
1 & 1 & \dots & 1 \\
x_{11} & x_{21} & \dots & x_{n1} \\
\vdots & \vdots & \ddots & \vdots \\
x_{1p} & x_{2p} & \dots & x_{np}
\end{pmatrix}
\end{align*}
\end{document}

enter image description here

\documentclass{article}
\usepackage{geometry}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
\begin{gathered}
H = \begin{pmatrix}
1 & x_{11} & \cdots & x_{1p} \\
1 & x_{21} & \cdots & x_{2p} \\
\cdots & \cdots & \cdots & \cdots \\
1 & x_{n1} & \cdots & x_{np} \\
\end{pmatrix}
%
\begin{pmatrix}
q_{11} & q_{12} & \cdots & q_{1p+1} \\
q_{21} & q_{22} & \cdots & q_{2p+1} \\
\cdots & \cdots & \cdots & \cdots \\
q_{p+11} & q_{p+12} & \cdots & q_{p+1p+1} \\
\end{pmatrix}
%
\begin{pmatrix}
1 & 1 & \cdots & 1 \\
x_{11} & x_{21} & \cdots & x_{n1} \\
\cdots & \cdots & \cdots & \cdots \\
x_{1p} & x_{2p} & \cdots & x_{np} \\
\end{pmatrix}
%
= \\
%
\begin{pmatrix}
x_{1}^{t}q_{1} & x_{1}^{t}q_{2} & \cdots & x_{1}^{t}q_{p+1} \\
x_{2}^{t}q_{1} & x_{2}^{t}q_{2} & \cdots & x_{2}^{t}q_{p+1} \\
\cdots & \cdots & \cdots & \cdots \\
x_{n}^{t}q_{1} & x_{n}^{t}q_{2} & \cdots & x_{n}^{t}q_{p+1} \\
\end{pmatrix}
%
\begin{pmatrix}
1 & 1 & \cdots & 1 \\
x_{11} & x_{21} & \cdots & x_{n1} \\
\cdots & \cdots & \cdots & \cdots \\
x_{1p} & x_{2p} & \cdots & x_{np} \\
\end{pmatrix}
\end{gathered}
\end{equation*}
\end{document}