- Why is that?
- Is it because this way you know that the blood line would be still okay or any other logical reason except for tradition?
It all has to do with the line of succession to the British Throne. In the case of the current Queen, Elizabeth II, the story of how she became Heiress presumptive is described on Wikipedia:
During her grandfather’s reign, Elizabeth was third in the line of succession to the throne, behind her uncle Edward, Prince of Wales, and her father, the Duke of York. Although her birth generated public interest, she was not expected to become queen, as the Prince of Wales was still young and many assumed he would marry and have children of his own. In 1936, when her grandfather, George V, died and her uncle succeeded as Edward VIII, she became second in line to the throne after her father. Later that year, Edward abdicated after his proposed marriage to divorced socialite Wallis Simpson provoked a constitutional crisis. Elizabeth’s father became king, and she became heiress presumptive. If her parents had had a later son, she would have lost her position as first in line as her brother would have been heir apparent and above her in the line of succession.
And her ascension to the throne:
During 1951, George VI’s health declined and Elizabeth frequently stood in for him at public events. When she toured Canada and visited President Truman in Washington, D.C. in October 1951, her private secretary, Martin Charteris, carried a draft accession declaration for use if the King died while she was on tour. In early 1952, Elizabeth and Philip set out for a tour of Australia and New Zealand by way of Kenya. On 6 February 1952, they had just returned to their Kenyan home, Sagana Lodge, after a night spent at Treetops Hotel, when word arrived of the death of the King. Philip broke the news to the new queen. Martin Charteris asked her to choose a regnal name; she chose to remain Elizabeth, “of course”. She was proclaimed queen throughout her realms and the royal party hastily returned to the United Kingdom. She and the Duke of Edinburgh moved into Buckingham Palace.
Laws of royal succession vary between monarchies. Some have inheritance in the male line only, but others do not. The UK has a tradition of allowing inheritance through the female line; and of women as monarchs in their own right, such as Elizabeth I of England (reigned 1558-1603), Mary of Scotland (1542-67), and Victoria (1837-1901).
At the time Elizabeth II became Queen, succession in the UK was sons in order of age, followed by daughters in order of age. So a younger son would take precedence over an older daughter.
This rule dated back to the reign of King Henry VIII of England (1509-47). Towards the end of his life, Henry had a young son named Edward; and two older daughters, Mary and Elizabeth. Edward was a child and in poor health, and it was doubtful whether he would live to adulthood and have children of his own. Henry had no surviving brothers, nephews, or other close male relatives who could become King. So he designated Mary and Elizabeth as his heirs after Edward. (All three children ended up inheriting the throne, as Edward VI, Mary I and Elizabeth I respectively.)
After this precedent was established by Henry VIII, it remained in effect for England and later for the UK.
The present Queen's father was King George VI, who had no sons. His children were Elizabeth and her younger sister Margaret. So upon the death of George VI in 1952, Elizabeth became Queen.
In 2013, the law was changed so that the oldest child of the previous monarch will inherit the throne, regardless of sex. This change affects the UK as well as Canada, Australia and other countries with the Queen as head of state. It had no effect on the current line of succession, which is entirely male: Prince Charles (oldest child of Elizabeth), Prince William (oldest child of Charles), and Prince George (oldest child of William).
You could simply turn the question and ask why not? The queen could have simply inherited the throne because she was the daughter of the previous king (and so on through various inheritances, succession wars, etc.). Implicit in your question however is the fact that male kings have been the rule in Europe for many centuries and understanding why also explains how it's possible to have queens as well.
Originally, Germanic kings were not hereditary rulers at all but were elected among warriors and were therefore necessarily males. As the institution became hereditary, the notion that the king had to be a man remained. But the thing is that while women had a very limited political role in the European Middle Ages, succession through female lines were never strictly excluded. Many European kingdoms then allowed queens to rule themselves (instead of merely transmitting an estate or title to their husband or son).
In this context, it's the fact that some countries (most famously France) did not allow succession through female lines under any circumstances that needs to be explained. And in the case of France, it can in fact readily be explained. Starting in the 14th Century, French lawyers revived and hardened the so-called “salic law” to fight English claims to the kingdom of France.
Apart from this and a handful of other exceptions, women could always inherit a kingdom and European countries now also allow both male and female monarchs. But it's only very recently that some countries moved to absolute primogeniture. Following the Perth agreement, England and other Commonwealth realms did it in 2015.