I mean who, when and how it is decided that A is the first letter and B will come next and Z will be the last one.
Thanks for answering.
The history of the Latin alphabet goes back a few milennia, and most of the letters and their position appear already back in the 2nd milennium BC. It is commonly accepted that the Latins adopted their alphabet from the ones the Etruscans used. Those in turn adopted a form of the Greek alphabet, which evolved out of the phoenician alphabet.
It has been commonly assumed that our letters and the phonetic values for them go back to the so-called proto-sinaitic or proto-semitic script - which is not really an alphabet, but an abjad, that means, it has no signs for vocals, only consonants. The basic argument is that the proto-sinaitic script used some hieroglyphs, and then gave them the phonetic value of the intital of the semitic translation of the hieroglyphic symbol, thus the hieroglyphic symbol for 'house', which is beth in the semitic, became 'B', the door, daleth, became D, the bovine ʔaleph became ʔ, which is the glottal stop sometimes found before A. The problem with this theory is that it relies on little concrete evidence and much conjecture. Zauzich, an Egyptologist, has argued in his recent book Hieroglyphen mit Geheimnis (Mainz 2014), that the semitic alphabet has a more direct influence in the cursive version of Egyptian hieroglyphs, the so-called hieratic script, which closely map to the semitic script. Earlier scholars like Bauer had already criticized this 'acrophonic' theory.
In any case, there is a clear trend around the middle of the 2nd milennium BC, where both cuneiform and hieroglyphic scripts adopt some form of abjad that can be used to represent consonants independent of the symbols 'meaning', for hieroglyphs this is the hieratic script, and for cuneiform we have the ugaritic script, which already follows a certain order. Here is a clay tablet containing the ugaritic abjad. The signs are alpa, beta, gamla, delta, ho, wo, zeta, hota, ted, yot, haf, lambda, mem, nun, samka, 'ain, pu, sade, qopa, rasha, sin, to, ha, da, ẓu, ṯanna, gain, i, u, ṡu and šinš.
The beginning at least should sound familiar, even if the shapes at first glance seem not. What is interesting here is that it corresponds in names, phonetic value and order closely to the common ancestor of the modern Latin, Greek, Arabic and Hebraic alphabets, the Phoenician script and its earlier proto-semitic or proto-canaanite forms. So it is at this time, around 1.500 BC, that the modern alphabet already seems to crystallize in the cultural interactions of the near east. If we look at the phoenician alphabet, or abjad in that case, from around 1.200 BC we can maybe see it a bit more clearly:
http://www.ancientscripts.com/images/phoenician.gif
This abjad only had 22 letters, but it formed the basis for the evolution of the Greek alphabet. The phoenicians were traders with influence reaching all over the mediterranean, and around the turn of the milennium, the Greeks begin to adopt and adapt this way of writing, probably first at Rhodos, spreading from there to Korinth, Crete, and so on, and at first only with those 22 letters (in their modern forms):
ΑΒΓΔΕFΖΗΘΚΛΜΝΞΟϘΠMΡΣΤΥ
There are a few basic changes here, without going too much into detail the Greeks adopted the names of the letters to better fit the idiosyncrasies of their language (such as in the vocalic endings), the waw, Y, split into two graphs depicting different similar sounds, F or Digamma and Y or ypsilon for the vocalic u (Y for 'u' gets added to the end) and some letters such as A changed their phonetic values, others such as sin their orientation (by 90 degrees to form sigma).
The exact processes are pretty complicated, but here, as in other cases where alphabets are adapted to new languages, glyphs change what sounds they represent to fit the new language, superfluous glyphs, that depict similar phonemes or those that don't exist in the new language get omitted, and new ones are found to represent phonemes not yet represented.
As a result of this, the sade, the second 'M' gets omitted and sigma, Σ stays. Qoppa, Ϙ, and Digamma, F, share their fates. New letters get invented to represent the sounds p+s (Ψ), Psi, and the aspirated k+h (Χ), Chi, and p+h (Φ), Phi, as well as the long 'o' or Omega (Ω), which simply get added to the end of the Alphabet, giving us the Greek alphabet:
ΑΒΓΔΕΖΗΘΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ
The so-called Euboean form of the Greek alphabet, which can be seen to the left here, which kept the sade and didn't have the chi and omega, is seen as the most likely candidate for the basis of the so-called old-italic scripts, of which Etruscan is a form. The Etruscan alphabet looks as this:
𐌀𐌁𐌂𐌃𐌄𐌅𐌆𐌇𐌈𐌉𐌊𐌋𐌌𐌍𐌎𐌏𐌐𐌒𐌓𐌔𐌕𐌖𐌗𐌘𐌙𐌚
The Digamma, or 𐌅, here still has the value of v, while 𐌚 is the 'f' sound. The Latins adopted this alphabet for their own use, omitting a lot of the 26 letters used in the etruscan:
ABCDEFZHIKLMNOPQRSTVX
This is the latin alphabet used in its first autonomous incarnation, after adaptation from the Etruscans. They left out the Greek letters they did not need at the end (𐌘, 𐌙, 𐌚) and changed the value of the etruscan 𐌅 to that of 'f'. Some of those letters were used to represent numbers instead (like 𐌘 for thousand, or ( | ), which also gives us the halved form, | ) or D for 500).
ABCDEFGHIKLMNOPQRSTVX
The next evolution was to get rid of the Z, which represented a voiced s that wasn't needed. Also, a new letter was invented and put in place of the Z, the G, a slight modification of C. I've read the argument that this was to preserve the numeric values of the alphabet (A=1, B=2, and so on). In this form, the Alphabet stayed throughout republican times.
ABCDEFGHIKLMNOPQRSTVXYZ
In the first century BC, Greek loan words and names, whose prominence increased with the conquest of Greece, begun to be written with the Greek letters Y and Z instead of using V and S or SS, so Y and Z made their comeback. Emperor Claudius tried to introduce new characters to the alphabet to close gaps in the alphabet to represent certain sounds: Ⅎ for a voiced fricative w, Ⱶ for a short greek y, a sound between e and i and a third one for bs/ps, which is only known from one source and looked something like a warped X. Obviously, his suggestions didn't catch on.
ABCDEFGHIJKLMNOPQRSTUVWXYZ
The distinction between I and J was originally just a stylistic variation and only became associated with the different sounds in later times, but the graphical variation already emerged in Roman times, where it was f.e. used at the end of numbers: XIIJ for 13, with the lower bow of the J extending below the line, like it does in lower case (ij). U is similar, in that there was originally no distinction between the value of U and V.
W came to be as a ligature of VV, which gives us the present Latin alphabet.
Of course there are countless variations and especially ligatures which became their own characters (like Æ, Œ, Ä, Ö, Ü) or letters that are only used in regional alphabets, like Ø, or regional alphabets that use letters from other alphabets (e.g. Icelandic with Þ and ð), to adopt the alphabet to their language with the necessary modifications to represent most all the sounds used in that language.
The reason that it always stayed in the same basic order is often assumed to be in the way the alphabet was learned: that is, by rote memorization. Quintillian, the Roman rhetorian, criticizes this, but according to him small children learned the letters and their order by repeating them over and over, forwards and backwards, without learning their shapes. In fact, we have early aphabetic inscriptions (so called abecedaria are often found, many of which must be the remnant of pupils learning to write the alphabet) from Greek cities in southern Italy often include even those phoenician letters that weren't needed anymore in their respective places.