Freemasonry is a fraternal organization that traces its origins to the local fraternities of stonemasons, which from the end of the fourteenth century regulated the qualifications of stonemasons and their interaction with authorities and clients. The current degrees of freemasonry retain the three grades of the medieval craft guilds, those of Apprentice, Fellow-craft, and Master Mason. These are the degrees offered by a modern Masonic Lodge.
During medieval times, stonemasons built the magnificent structures we still admire today. To work on various projects, craftsmen were employed by their skill level. The Master Mason needed to identify the individual craftsmen and the ability of their skill. Apprentices, were capable of performing basic stone mason work and were able to identify themselves as such to the Master Mason on the project. The same was true for the Fellow-crafts and other Master Mason, who were put to work with greater responsibilities. In those times you had to belong to the fraternity to be able to work on a project. Invitations to join the fraternity as you can imagine, were passed down from generation to generation and to members of one's close inner circle. Even in those times, it was understood, that by keeping the secrets of stone masonry within a small group, that group could command higher wages and a relatively stable life. Imagine, your fraternity was the only group able to be commissioned to build castles for kings and cathedrals for the church.
By keeping their skills of stone masonry a secret, members of the fraternity insured a good future as they saw the need of construction in the forthcoming generations. In medieval times as continues today, there is a process in place to move up from one degree to another. In the past, this insured that no member of the fraternity would go rouge, and disclose the secret skills of a stonemason. This would have been bad for the overall fraternity as it would allow for the hiring of non-stonemasons to work on projects.
Modern Freemasons are not building castles or cathedrals any more, and similarities with medieval stonemasons are mostly symbolic, but we live with the same spirit of fraternity.
In the following years, the Knights Templar became intertwined in the history of the masons. Much of that history is speculative, but some is not.
I will leave it up to you to research and make your own decisions. There are many books on the subject and the internet is full of information. Modern masons don't really provide a solid source on this topic, since we are talking about ancient history. Really, the best way to approach this, is to read and research and educate yourself. If you find that you are compelled to learn more, visit a local lodge and make it your goal to experience the same rituals masons have been going through for hundreds of years, the answer to your questions may be found in your own experiences.
Freemasonry is a global fraternity of men who believe in the brotherhood of Man under the Fatherhood of God. As such, Freemasons strive to uphold moral character and spiritual values in their interactions with all members of the human family.