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
The lines are indeed visualisations to represent a vector field.
At each point in space there is a magnetic field strength and a direction for that field.
The left hand diagram is such a representation for the magnetic field around a current carrying conductor with the current coming out of the screen.
If it was correctly drawn then the length of each of the arrows should be inversely proportional to the distance from the centre.
So this diagram gives you information about magnitude and direction.
The representation that you are perhaps more familiar with is thet in the right when the tangent to a field at a point gives the direction of the magnetic field line.
To illustrate the fact that the field is stronger near the conductor the concentric circles are drawn closer to one another.
So perhaps the second diagram does not have as much information on it as the first but it is significantly easier to draw.
However there diagrams are incomplete in that the magnetic fields are actually three dimensional and then the drawing of such diagrams becomes even more difficult.
Historically the magnetic flux density was the number of field lines per unit area and that is were the term flux (= flow) comes from with magnetic flux being the total number of lines.
You will still find lots of textbooks which are in esu, emu, cgs and Gaussian units from a time when there were also magnetic poles which followed an inverse square law just like Coulomb's law for electric charges.
So going back to your queries and the statement you made that they the magnetic field lines are visualisations and so you have some degree of artic licence with them provided you follow the simple properties:
Start and finish on themselves although it is often much clearer if you have them starting on a North pole and finishing on a South pole.
The arrow on a magnetic field line goes away from a North pole and goes towards a South pole or follows the right hand grip rule for currents.
Magnetic field lines are in a state of tension. That is why a North pole attracts a South pole!