The order of the elements in the periodic table generally coincides with its increasing atomic number. Elements that lie in the same group have identical valance electron configurations and therefore have the same chemical properties. The noble gases being inert are grouped together. The period number(row) of an element on the other hand signifies the highest energy level an electron in that element occupies. Noble gases being stable with its electrons having the highest energy level are organised on the right end (group 18) of the table.
As for lanthanides and actinides , are often together termed as the "f elements" because they have their valence electrons in the "f shell" therefore organised together in the "f block". And, they are separated from the rest of the table due its electron configuration.