Motivation for Ramanujan’s mysterious π\pi formula

The following formula for $\pi$ was discovered by Ramanujan:

Does anyone know how it works, or what the motivation for it is?

Update: Just to make this more intriguing, define the fundamental unit $U_{29} = \frac{5+\sqrt{29}}{2}$ and fundamental solutions to Pell equations,