The "lines" you see when viewing iron filings around a magnet have more to do with the fact that they are tiny slivers of iron, and less to do with magnetic field lines as one normally talks about them.
Also, over the length scale of one of these slivers, the magnetic field is largely constant, and a ferromagnet (or magnetic dipole) placed in a constant magnetic field will not accelerate (it will, however, align itself with the field). Once two slivers line themselves up head to tail, the field they create around them makes it more favorable for other slivers to join the chain rather than to lie haphazard, because the filings distort the field around them. So it is simply energetically preferred for these slivers to line up head to tail and form longer chains, but if you look closely, the chains break and merge.
Magnetic field lines are just a way of visualizing magnetic fields, in the same way that electric field lines are used to visualize electric fields (lines of force). There are no "gaps" between true magnetic field lines -- they occupy all space. We just draw them that way to convey a sense of their intensity.
I also don't quite agree with the statement that friction prevents them from clustering on the magnet. It's a bit more complicated than that, and, indeed, you can watch the same behaviour in air by suspending a magnet above the filings and allowing them to lift up. Once the filings start attaching themselves to the magnet, a magnetic circuit is created which changes how the field looks.
First doubt: Why do magnetic field lines form closed curves?
The premise is false!
Take the following image I generated as an example. The black circles here are two current loops arranged haphazardly. The blue line is a single magnetic field line, plotted for a really long length. It's still going, and it isn't ending any time soon.
The only statement of importance is that $\nabla \cdot \vec{B}=0$. This can be interpreted differently: the divergence of a vector field at a point can be approximated by the flux into a very small sphere of volume $V$ at that point:$$\nabla \cdot \vec{B}=\lim_{V\to 0}\frac{\oint_S\vec{B}\cdot d\vec{a}}{V} $$
($S$ denotes the surface of the sphere volume $V$ centered at the point in question, and $d\vec{a}$ denotes a vector area element). Therefore, if a magnetic field line penetrates the tiny sphere and ends, and has some magnitude, then $\nabla \cdot \vec{B}\neq 0$ and you've violated a Maxwell law!
But a magnetic field line can actually end. For example, imagine two single loop solenoids on top of each other, pointing in opposite directions. As derived on this page, we might have:
$$B_z=-\frac{\mu_0 R^2 I}{2((z-a)^2+R^2)^{3/2}}+\frac{\mu_0 R^2 I}{2((z+a)^2+R^2)^{3/2}}$$
At $z=0$, the field is zero. At $z<0$, the field is positive and along the z axis. At $z>0$, the field is negative and along the z axis. So clearly the field line heads towards zero, but never reaches it.
Second doubt: Why do we say that the strength of the magnetic field is
more where the lines are closer together?
The following page defines $B=\sqrt{\vec{B}\cdot \vec{B}}$ and $\hat{b}=\vec{B}/B$, and proves that as you walk along a field line:
$$\frac{dB}{d\ell}=\hat{b}\cdot \nabla B=-B \nabla \cdot \hat{b}$$
If the field lines are converging then $\nabla \cdot \hat{b}<0$ and so $B$ is increasing in magnitude, and if the field lines are diverging then $\nabla \cdot \hat{b}>0$ and so $B$ is decreasing in magnitude. So there's your vector calculus proof.
J.D Callen, Fundamentals of Plasma Physics, chapter 3
Third: Why do iron fillings acquire exactly the design of the magnetic
field?
This is more complicated. Each iron filing forms a little magnet that attracts its neighbors, so the iron filings can't fill up space and instead join end to end in directions induced by the magnetic field. So they form lines. Which field lines are chosen depends on the whole, ugly dynamics of the situation.
Last doubt: The diagram of the magnetic field lines that we see (the 2D diagram with many curves), is that diagram 3D in reality?
Yep, Maxwell's equations in their vector calculus form work only in 3D, so the lines you get, in general, are three dimensional lines.
Mathematica source code for generating the .gif
Best Answer
First of all, there is no real or observable lines. Even the magnetic and electric fields are nice and abstract fields which describe observable forces. The term "line" you read is an old unit of magnetic flux. One line is the flux of a uniform magnetic field of one gauss across a surface of one square centimeter perpendicular to the field, $$1\ line = 1 G\cdot cm^2 = 10^{-8} Wb.$$
I suppose the origin of this name is related to the fact that we normally associate magnetic flux with the difference between lines crossing out and in a surface. Just like the flow of a fluid. However it is still an analogy, nothing else but a way to visualize the flux.
The "gap" between them is also a "representation". As Faraday told us, the tangent along the lines give us the direction of the field while the density of the lines give us the intensity of the field. There definitely is field in between the drawn lines.