Why is $e^{\pi \sqrt{163}}$ almost an integer? The fact that Ramanujan's Constant $e^{\pi \sqrt{163}}$ is almost an integer ($262 537 412 640 768 743.99999999999925...$) doesn't seem to be a coincidence, but has to do with the $163$ appearing in it. Can you explain why it's almost-but-not-quite an integer in layman's terms (I'm not a mathematician)?
 A: This is quite a challenge to express in "layman's terms", but the
reason is that
$$j\left(\frac{1+\sqrt{-163}}{2}\right)$$
is an integer where $j$ is the $j$-function. When you substitute
$(1+\sqrt{-163})/2$ into the $q$-expansion (see the wikipedia page)
of $j$, all terms save the first two are small, and the first two equal
$$-\exp(\pi\sqrt{163})+744.$$
The reason that this $j$-value is an integer is due to the quadratic
field $\mathbb{Q}(\sqrt{-163})$ having
class number one, or equivalently that all positive-definite
integer binary quadratic forms of discriminant $-163$ are equivalent.
Added
I'll try to explain the connection with binary quadratic forms. Consider
a quadratic form
$$Q(x,y)=ax^2+bxy+cy^2$$
with $a$, $b$ and $c$ integers. I'll only consider forms $Q$ which are
primitive, so that $a$, $b$ and $c$ have no common factor $ > 1$,
and positive-definite, that is $a > 0$ and the discriminant
$D=b^2-4ac < 0$. There is a notion of equivalence of quadratic forms,
and two primitive positive-definite forms $Q$ and $Q'(x,y)=a'x^2+b'xy+c'y^2$
(necessarily also of discriminant $D$) are equivalent if and only if
$$j\left(\frac{b+\sqrt{-D}}{2a}\right)
=j\left(\frac{b'+\sqrt{-D}}{2a'}\right).$$
For each possible discriminant there are only finitely many equivalence
classes. Thus we get a finite set of $j$-values for each discriminant, and
the big theorem is that they are the solutions of a monic algebraic equation
with integer coefficients. When there is only one class the equation has the
form $x-k=0$ where $x$ is an integer, and the $j$-value must be an integer.
My recommended reference for this is David Cox's book
Primes of the form $x^2+ny^2$. But these results appear towards
the end of this 350-page book.
A: I do not think "why" has a reasonable layman's-terms answer, but let me at least explain "how" with a simpler example of such a numerical coincidence.  If one takes powers of the golden ratio $\phi = \frac{1 + \sqrt{5}}{2}$ it is not hard to see that they are close to integers.  For example, $\phi^{20} = 15126.999934...$.  One might ask an analogous question about why these numbers are close to integers.  The answer is that 
$$\phi^n + \varphi^n = L_n$$
where $L_n$ is the $n^{th}$ Lucas number (an integer), and where $\varphi = \frac{1 - \sqrt{5}}{2}$ has absolute value less than $1$.  As $n$ gets larger, $\varphi^n$ gets smaller, so $\phi^n$ becomes a better and better approximation to the integer $L_n$.  
A similar, but much more complicated, phenomenon is happening here.  The reason $e^{\pi \sqrt{163}}$ is so close to an integer is that it, plus a small error term, gives a special formula for that integer.  But "why" this formula exists is a rather long and complicated story (as Robin Chapman hints at) and I do not think there is any reasonable way to talk about it in layman's terms.  
A: As QY pointed out this cannot be explained in layman terms: Here are the papers which you would like to see: www.isibang.ac.in/~sury/ramanujanday.pdf
http://www.isibang.ac.in/~sury/episq163.pdf
A: I know it's super late but in case anyone has this question in the future, Richard Borcherds made a really digestible video on it in 2020: https://www.youtube.com/watch?v=a9k_QmZbwX8&list=PLar4u0v66vIodqt3KSZPsYyuULD5meoAo&index=85
